Skip to content

Instantly share code, notes, and snippets.

@arnab
Created February 20, 2012 03:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arnab/1867556 to your computer and use it in GitHub Desktop.
Save arnab/1867556 to your computer and use it in GitHub Desktop.
def some_method(other_method, args)
puts "before"
other_method.call args
puts "after"
end
def other_method(stuff)
puts "other_method called with #{stuff.inspect}"
end
m = method(:other_method)
# => #<Method: Object#other_method>
some_method(m, [1,2,3])
# before
# other_method called with [1, 2, 3]
# after
m.class
# => Method
m.methods - 1.methods
# => [:call, :arity, :to_proc, :receiver, :name, :owner, :unbind, :source_location, :parameters]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment