Martin DeMello
12/13/2005 4:49:00 AM
Dan Diebolt <dandiebolt@yahoo.com> wrote:
> --0-185724427-1134433774=:47703
> Content-Type: text/plain; charset=iso-8859-1
> Content-Transfer-Encoding: quoted-printable
>
> > ... in this context.=20
> =20
> Very clever. The hash's brackets disguise the context. I tried this con=
> text but no joy:=20
> =20
> irb> *["apple", "bananna", "orange", "grape]
The * converts an array to a comma separated list (what David Black
dubbed the "unary unarray operator"). Therefore, it needs to be used in
a context where a comma separated list of the array's contents would
make syntactic sense. Also, for some reason (anyone know why?) it can't be
inserted anywhere other than at the end of an existing list, so that
e.g.
a, b, c, d = 1, 2, *[3,4] # works
a, b, c, d = 1, *[2,3], 4 # syntax error
martin