Created
July 3, 2012 14:21
-
-
Save cgiacomi/3040002 to your computer and use it in GitHub Desktop.
Set a function as a value in a Hash, and how to call it with arguments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def myfunc(arg) | |
puts arg | |
end | |
dict = {} | |
dict['greet'] = method(:myfunc) | |
f = dict['greet'] | |
f.call('Hello World') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment