Created
October 11, 2011 06:31
eXtreme Polymorphysm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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