From: Robert Klemme Date: 2008-03-02T21:14:57+09:00 Subject: Re: simple question re Hash and arrays On 02.03.2008 12:58, Esmail wrote: > Esmail wrote: >> Hello all, >> >> How come Hash[1,2,3,4] works, but >> >> a=[1,2,3,4] >> >> Hash[a] doesn't? > > but Hash[*a] does? > > a is an array, what is *a ?? It's also an Array. "*" is the "spash operator" that will expand an Array to the argument list. irb(main):001:0> def f(*a) p a end => nil irb(main):002:0> f(1,2,3) [1, 2, 3] => nil irb(main):003:0> a=[1,2,3] => [1, 2, 3] irb(main):004:0> f a [[1, 2, 3]] => nil irb(main):005:0> f a,33 [[1, 2, 3], 33] => nil irb(main):006:0> f *a [1, 2, 3] => nil irb(main):007:0> Cheers robert