```On Sat, Dec 5, 2009 at 9:22 AM, Ruby Newbee <rubynewbee / gmail.com> wrote:
> 2009/12/5 Andrey Zaikin <zed.0xff / gmail.com>:
>> irb(main):001:0> a=["a", "hello", "b", "world", "c", "welcome", "d",
>> "baby"]
>> => ["a", "hello", "b", "world", "c", "welcome", "d", "baby"]
>> irb(main):002:0> Hash[*a]
>
> Thanks.
> What's the "*" before "a" then?

It's the splat operator. It's used to "unarray" an array into its
individual items to pass them to a method:

irb(main):007:0> def m(a,b,c)
irb(main):008:1> p a
irb(main):009:1> p b
irb(main):010:1> p c
irb(main):011:1> end
=> nil
irb(main):012:0> x = [1,2,3]
=> [1, 2, 3]
irb(main):013:0> m *x
1
2
3

or to collect individual elements into an array when it appears in a lvalue:

irb(main):014:0> a,*b = [1,2,3,4,5]
=> [1, 2, 3, 4, 5]
irb(main):015:0> a
=> 1
irb(main):016:0> b
=> [2, 3, 4, 5]

or argument list of a method:

irb(main):020:0> def m(a,*b)
irb(main):021:1> p a
irb(main):022:1> p b
irb(main):023:1> end
=> nil
irb(main):024:0> m(1,2,3,4,5,6)
1
[2, 3, 4, 5, 6]

Hope this helps,

Jesus.

```