Skip to content

Instantly share code, notes, and snippets.

@Hanmac
Forked from repomaa/03-lottery.rb
Last active December 16, 2015 10:28
Show Gist options
  • Save Hanmac/5419912 to your computer and use it in GitHub Desktop.
Save Hanmac/5419912 to your computer and use it in GitHub Desktop.
def draw n=6
to_enum(__method__) unless block_given?
draw_all(n).each do |number|
break unless number
yield number
end
end
def draw_sorted n=6
to_enum(__method__) unless block_given?
draw(n).to_a.sort.each { |number| yield number }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment