Skip to content

mhanberg/loop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Loop

Blursed be the loop...

The most blursed of all programming constructs, the infinite loop.

use Loop

counter = :counters.new(1, [])

loop do
  count = :counters.get(counter, 1)
  # Break the loop completely
  break if count == 10

  if Enum.random(1..100) < 20 do
    IO.puts "Sleeping..."
    Process.sleep(2000)

    # Proceed directly to the next iteration of the loop
    next()
  end

  IO.puts "Incrementing!"

  :counters.add(counter, 1, 1)
end