Created
March 30, 2019 06:26
-
-
Save okuramasafumi/f42678e0c8d7668729633112f1eac063 to your computer and use it in GitHub Desktop.
Hash to_proc demo
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
hash = {foo: 1, bar: 2, buzz: 10} | |
words = %i(foo bar buzz) | |
p words.map(&hash) # => [1, 2, 10] | |
proc_obj = hash.method(:[]).to_proc | |
p words.map(&proc_obj) # => [1, 2, 10] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment