-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloop.rb
More file actions
109 lines (65 loc) · 1.1 KB
/
loop.rb
File metadata and controls
109 lines (65 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#While loop demo
#Display a message 5 times
#Initialize a loop variable
# count = 0
# #while loop begins
# while ( count < 5 ) do
# puts "\nInside while loop!"
# #Increment loop variable
# count = count + 1
# end
#Until loop demo
#Display multiples of 3
#Initialize a loop variable
# count = 1
# #until loop begins
# until ( count == 11 ) do
# puts "\n #{count * 3}"
# #Increment loop variable
# count = count + 1
# end
# for i in 1..10
# puts i
# end
# for i in [1,2,3,4,5,6,7,8,9]
# puts i
# end
# loop do
# puts "Enter a num greater than 10"
# num = gets.chomp.to_i()
# if num > 10
# break
# end
# end
# i = 1
# until i == 10
# puts i * 2
# i += 1
# end
# x = 3
# unless x < 5
# puts "X is greater or equal to 5"
# else
# puts "X is less than 5"
# end
# end
# for i in 1..10
# if i == 5
# next
# end
# puts i
# end
# x = 1
# while x < 5
# puts x
# x += 1
# redo if x ==5
# end
for i in 1..10
begin
puts i
raise if i == 10
rescue
retry
end
end