Created
October 29, 2014 18:32
-
-
Save jferris/871840d40347e4e1e7b3 to your computer and use it in GitHub Desktop.
Compose Functions in Ruby
This file contains hidden or 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 String | |
def blank? | |
self == "" | |
end | |
end | |
class Symbol | |
def *(other) | |
lambda { |instance| instance.__send__(other).__send__(self) } | |
end | |
end | |
strings = ["one", "", "two"] | |
p strings.map(&:!*:blank?) | |
# => [true, false, true] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment