Skip to content

Instantly share code, notes, and snippets.

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 knzconnor/46673 to your computer and use it in GitHub Desktop.
Save knzconnor/46673 to your computer and use it in GitHub Desktop.
def foo(value)
"#{value}foo"
end
[1,2].map &method(:foo)
#=> ["1foo", "2foo"]
def foo(value)
"#{value[0]}foo"
end
[[1,2],[3,4]].map &method(:foo)
# ArgumentError: wrong number of arguments (2 for 1)
# from (irb):13:in `foo'
# from (irb):13:in `to_proc'
# from (irb):14:in `map'
# from (irb):14
# from :0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment