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