Skip to content

Instantly share code, notes, and snippets.

@morenocarullo
Created October 11, 2011 06:31
Show Gist options
  • Save morenocarullo/1277431 to your computer and use it in GitHub Desktop.
Save morenocarullo/1277431 to your computer and use it in GitHub Desktop.
eXtreme Polymorphysm
class FalseClass
def if_false(&block)
block.call
self
end
def if_true(&block)
self
end
end
class TrueClass
def if_true(&block)
block.call
self
end
def if_false(&block)
self
end
end
# example
(1>2).if_true{puts "yes"}.if_false{puts "no"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment