Creating an infinite loop

infinite-loop, loops, ruby

Solution

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

Problem

I'm trying to create an infinite loop, where a block of code will be executed forever. All loop documentation I have found warns against creating an infinite loop, but no examples of a working one. If I have a block of code: ``` { puts "foo" puts "bar" sleep 300 } ``` How would I go about running this block forever?

Original source