Skip to content

Instantly share code, notes, and snippets.

@jferris
Created October 29, 2014 18:32
Show Gist options
  • Save jferris/871840d40347e4e1e7b3 to your computer and use it in GitHub Desktop.
Save jferris/871840d40347e4e1e7b3 to your computer and use it in GitHub Desktop.
Compose Functions in Ruby
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