Skip to content

Instantly share code, notes, and snippets.

@luislee818
Created October 29, 2014 14:06
Show Gist options
  • Save luislee818/902f2fb18fd2efe068c5 to your computer and use it in GitHub Desktop.
Save luislee818/902f2fb18fd2efe068c5 to your computer and use it in GitHub Desktop.
Pass method as argument in Ruby
class Foo
def foo
r = helper method(:bar)
# r = helper Proc.new { bar }
puts r
end
def bar
3
end
end
def helper(fn)
fn.call
end
f = Foo.new
f.foo # 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment