Martin DeMello
3/20/2007 2:40:00 PM
On 3/20/07, Servando Garcia <garcia.servando@gmail.com> wrote:
>
> David
> No Way that is to easy. My new question to you is how does this work.
> Where can I read the source code for this method
It's a combination of two things:
1. Hash.[] creates a hash from a comma separated even-length list
Hash[1,2,3,4,5,6] # => { 1=>2, 3=>4, 5=>6 }
2. *ary converts an array into a comma-separated list
def foo(a, b=nil, c=nil)
p a
p b
p c
end
ary = [1,2,3]
def foo(a, b=nil, c=nil)
p a
p b
p c
end
ary = [1,2,3]
irb> foo(ary)
[1, 2, 3]
nil
nil
=> nil
irb> foo(*ary)
1
2
3
=> nil
martin