timocratic (owner)

Revisions

gist: 46673 Download_button fork
public
Public Clone URL: git://gist.github.com/46673.git
Problems with Method#to_proc that get passed an array
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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