Perl 6 Perl 6 today #21

Constant hash key lookups

We commonly use angles for constant-key hash lookups:

my %scores = < pmichaud 52   mäsak 95   PerlJam 78 >;

say %scores{'pmichaud'};    # hash lookup

say %scores{ <pmichaud> };  # same

say %scores<pmichaud>;      # same, Perl 6 shortcut

Note the difference between angles and curlies:

%scores<foo>          # same as %scores{ 'foo' }
%scores{foo}          # same as %scores{ foo() }
Copyright © 2009
http://www.pmichaud.com/2009/pres/