Skip to content

Instantly share code, notes, and snippets.

@okuramasafumi
Created March 30, 2019 06:26
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 okuramasafumi/f42678e0c8d7668729633112f1eac063 to your computer and use it in GitHub Desktop.
Save okuramasafumi/f42678e0c8d7668729633112f1eac063 to your computer and use it in GitHub Desktop.
Hash to_proc demo
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