Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Hash creation with duplicate keys

47 views
Skip to first unread message

Ingo Blechschmidt

unread,
Jul 20, 2005, 8:42:30 AM7/20/05
to perl6-l...@perl.org
Hi,

# Perl 5
my %hash = (a => 1, b => 2, a => 3);
warn $hash{a}; # 3

But I vaguely remember having seen...:

# Perl 6
my %hash = (a => 1, b => 2, a => 3);
say %hash<a>; # 1

Can somebody confirm this?


--Ingo

--
Linux, the choice of a GNU | Mathematicians practice absolute freedom.
generation on a dual AMD | -- Henry Adams
Athlon! |

Luke Palmer

unread,
Jul 21, 2005, 1:21:05 PM7/21/05
to Ingo Blechschmidt, perl6-l...@perl.org
On 7/20/05, Ingo Blechschmidt <ibl...@web.de> wrote:
> Hi,
>
> # Perl 5
> my %hash = (a => 1, b => 2, a => 3);
> warn $hash{a}; # 3
>
> But I vaguely remember having seen...:
>
> # Perl 6
> my %hash = (a => 1, b => 2, a => 3);
> say %hash<a>; # 1
>
> Can somebody confirm this?

Yes. This is for the case:

foo(a => 1, *%defaults);

So that foo's $a gets one even if it exists in %defaults.

Luke

Larry Wall

unread,
Jul 21, 2005, 1:59:45 PM7/21/05
to perl6-l...@perl.org

It's likely that the leftmost-wins rule applies only to binding,
not assignment.

Larry

0 new messages