? ??
1/8/2009 11:54:00 AM
thanks for all your replies.
2009. 01. 08, =EC=98=A4=ED=9B=84 8:46, Eust=C3=A1quio Rangel =EC=9E=91=EC=84=
=B1:
> Hi!
>
> 2009/1/8 Jun Young Kim <jykim@altibase.com>:
>> what's the definition of '*'?
>> is this pointer?
>
> It's called "splat operator". You can use it to "explode" your array
> elements or join some variables on an array. Note the difference:
>
> irb(main):001:0> a =3D [1,2]; b =3D [3,4]
> =3D> [3, 4]
> irb(main):002:0> a.push(b)
> =3D> [1, 2, [3, 4]]
> irb(main):003:0> a.push(*b)
> =3D> [1, 2, [3, 4], 3, 4]
>
> And now:
>
> irb(main):004:0> def test(*args)
> irb(main):005:1> p args
> irb(main):006:1> end
> =3D> nil
> irb(main):007:0> test(1)
> [1]
> =3D> nil
> irb(main):008:0> test(1,2,3)
> [1, 2, 3]
>
> Regards,
>
>