Creating an infinite loop

Here are some examples of infinite loops using blocks.

Loop

loop do
  puts "foo"  
  puts "bar"  
  sleep 300
end

While

while true
  puts "foo"  
  puts "bar"  
  sleep 300
end

Until

until false
  puts "foo"  
  puts "bar"  
  sleep 300
end

Lambda

-> { puts "foo" ; puts "bar" ; sleep 300}.call until false

There are a few variations of the lambda as well, using the non-stabby lambda syntax. Also we could use a Proc.

Begin..End

begin
  puts "foo"  
  puts "bar"
  sleep 300
end while true

I have tried all but with inputs loop only worked as infinty loop till I get a valid input:

loop do
    a = gets.to_i
    if (a >= 2)
        break
    else 
        puts "Invalid Input, Please enter a correct Value >=2: "
    end
end

loop do
  puts 'foo'  
  puts 'bar'  
  sleep 300
end