What are the Ruby rules regarding the number of parameters for various functionally similar constructs and what are they called?
eg. I noticed that when blocks with several parameters pass one parameter of an array, it expands, and this does not seem to apply to methods. I often see this with the methods of the Enumerable module for a Hash object.
{a: 5}.map{|x| x}
{a: 5}.map{|k, v| [k, v]}
[[:a, 5]].map{|x| x}
[[:a, 5]].map{|k, v| [k, v]}
proc1 = Proc.new{|x| x}
proc1.call 5
proc1.call 5, 6
proc1.call [5, 6]
proc2 = Proc.new{|k, v| [k, v]}
proc2.call 5
proc2.call 5, 6
proc2.call [5, 6]
def f(k, v); [k, v] end
f 5
f 5, 6
f [5, 6]
def g(*vargs); vargs end
g 5
g 5, 6
g [5, 6]
However, the documentation for Proc.call does not seem to mention this.
Then there are also lambda that are slightly different, methods like Proc using &:name, and maybe some others. And I'm not quite sure what Proc.new{|x| x}.callexactly is the same as yieldin method_that_takes_a_block{|x| x}.