From: darren kirby Date: 2006-08-26T04:11:26+09:00 Subject: Re: What does *var mean? --nextPart6476853.dQsUu8Hp5F Content-Type: text/plain; charset="iso-8859-6" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline quoth the darren kirby: > quoth the Chih-Chao Lam: > > Apologies for a newbie ruby question: > > > > I know an asterisk can precede a parameter in the argument list of a > > method definition as in > > > > def varargs(arg1, *rest) > > def varargs(arg1, *rest) > puts arg1 > rest.each |arg| > puts arg > end > end > > > varargs(one, two, three, four, five) > > one > two > three > four > five > > > Really, it just accumulates a variable amount of arguments and presents > them in the function as a list. > > **kwargs will collect them in a hash. Sorry guy, I guess you know that. I am not sure about the other form but it= =20 appears to be syntactic sugar for building lists: irb(main):001:0> *d =3D 1,2,3,4,5 =3D> [1, 2, 3, 4, 5] > > Thanks, > > chao > -d =2D-=20 darren kirby :: Part of the problem since 1976 :: http://badcomputer.org "...the number of UNIX installations has grown to 10, with more expected..." =2D Dennis Ritchie and Ken Thompson, June 1972 --nextPart6476853.dQsUu8Hp5F Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) iD8DBQBE70tewPD5Cr/3CJgRAkY0AKDxhlAGcxIqXij0xSmJcMWlyq8nUACgx+uj pZsNyXmY3vPTtEnZOgQPs8o= =8AyZ -----END PGP SIGNATURE----- --nextPart6476853.dQsUu8Hp5F--