Skip to content

Instantly share code, notes, and snippets.

@rrichards
Forked from nyx/first_class_methods.rb
Created March 31, 2011 13:56
Show Gist options
  • Save rrichards/896384 to your computer and use it in GitHub Desktop.
Save rrichards/896384 to your computer and use it in GitHub Desktop.
class Adder
def initialize(a)
@a = a
end
def add_to(b)
@a + b
end
end
add_four_to = Adder.new(4).method(:add_to)
[1,2,3].map(&add_four_to)
# => [5, 6, 7]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment