Hi there, question about arrays and array refs in Rakudo today. I have array ref my $ar = [1,2,3]; how can I go over it?
I try: > my $r = [1,2,3]; say $r.elems; 3 > my $r = [1,2,3]; say $r.WHAT; Array > my $r = [1,2,3]; "Y".say for $r; Y > my $r = [1,2,3]; .say for $r; 1 2 3 #one string > my $r = <1 2 3>; for $r.list { "Y".say }; Y > my $r = [1,2,3]; my @a := $r; "Y".say for @a; Y Argh! :((( Any ideas? Ilya 2008/9/18 Илья <[EMAIL PROTECTED]>: > Thank you, I try three first too, but do not try :=. > > 2008/9/17 Moritz Lenz <[EMAIL PROTECTED]>: >> >> Илья wrote: >>> Hi, >>> I have some confusion. >>> I have $arref = [ 1, 2, 3 ]; >>> How I can assign it content to Array today in Rakudo? >> >> That's a good question, and I haven't found a simple answer. Here are my >> attempts so far: >> >> > my $a = [1, 2, 3]; my @b = @($a); say @b.elems >> 1 >> > my $a = [1, 2, 3]; my @b = @$a; say @b.elems >> Statement not terminated properly at line 1, near "= @$a; say" >> > my $a = [1, 2, 3]; my @b = list($a); say @b.elems >> 1 >> > my $a = [1, 2, 3]; my @b = list($a); say @b.elems >> 1 >> > my $a = [1, 2, 3]; my @b := list($a); say @b.elems >> 1 >> > my $a = [1, 2, 3]; my @b := $a; say @b.elems >> 3 >> >> So the last one seems to succeed, but it's really binding, not >> assignment, so @b and $a refer to the same variable after that. Change >> one, and you change the other. >> >> Moritz >> >> -- >> Moritz Lenz >> http://moritz.faui2k3.org/ | http://perl-6.de/ >> >> --~--~---------~--~----~------------~-------~--~----~ >> You received this message because you are subscribed to the Google Groups >> "november-wiki" group. >> To post to this group, send email to [EMAIL PROTECTED] >> To unsubscribe from this group, send email to [EMAIL PROTECTED] >> For more options, visit this group at >> http://groups.google.com/group/november-wiki?hl=en >> -~----------~----~----~----~------~----~------~--~--- >> >> >