What's the equivalent to "method reference" in Ruby
Posted
by Oscar Reyes
on Stack Overflow
See other posts from Stack Overflow
or by Oscar Reyes
Published on 2010-04-20T19:00:04Z
Indexed on
2010/04/20
19:03 UTC
Read the original article
Hit count: 226
ruby
|variable-reference
for instance in python it is possible to assign a method to a variable:
class MyClass
def myMethod(self):
return "Hi"
x = MyClass()
method = x.myMethod
print method() # prints Hi
I know this should be possible in Ruby, but I don't know what's the syntax.
© Stack Overflow or respective owner