Skip to content

Latest commit

 

History

History
29 lines (20 loc) · 475 Bytes

README.md

File metadata and controls

29 lines (20 loc) · 475 Bytes

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