ruby for loop

Shell
for i in 0..2 do 
  print(i)
end

# => 0
# => 1
# => 2for element in array do
  element.do_stuff
endwhile $i < $num  do
   puts("Inside the loop i = #$i" )
   $i +=1
end#!/usr/bin/ruby

$i = 0
$num = 5

while $i < $num  do
   puts("Inside the loop i = #$i" )
   $i +=1
end

# outputs
# Inside the loop i = 0
# Inside the loop i = 1
# Inside the loop i = 2
# Inside the loop i = 3
# Inside the loop i = 4
Source

Also in Shell: