Skip to content

Instantly share code, notes, and snippets.

@ELLIOTTCABLE
Created September 28, 2008 21:52
Show Gist options
  • Save ELLIOTTCABLE/13510 to your computer and use it in GitHub Desktop.
Save ELLIOTTCABLE/13510 to your computer and use it in GitHub Desktop.
def Coin █ Coin.new █ end
class Coin
def initialize &block
toss &block if block_given?
end
def toss &block
@toss = rand.round.zero?
yield
end
on :heads {|string| puts string } if @toss
on :tails {|string| puts string } unless @toss
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment