rails for loop code example
Example 1: ruby for loop
for i in 0..2 do
print(i)
end
# => 0
# => 1
# => 2
Example 2: rails loop
while $i < $num do
puts("Inside the loop i = #$i" )
$i +=1
end
for i in 0..2 do
print(i)
end
# => 0
# => 1
# => 2
while $i < $num do
puts("Inside the loop i = #$i" )
$i +=1
end