Skip to content

Instantly share code, notes, and snippets.

@dpick
Created April 3, 2012 03:48
Show Gist options
  • Save dpick/2289145 to your computer and use it in GitHub Desktop.
Save dpick/2289145 to your computer and use it in GitHub Desktop.
def bools(n)
generic(n) { rand > 0.5 }
end
def ints(n)
generic(n) { rand(0..10) }
end
def generic(n = rand * 10)
Enumerator.new do |yielder|
loop do
yielder.yield yield
end
end.take(n)
end
puts ints(10).inspect
puts bools(10).inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment