Anonymous user
Associative array/Creation: Difference between revisions
→{{header|Perl 6}}
m (→{{header|Sidef}}: modified code to work with Sidef 2.10) |
|||
Line 1,939:
=={{header|Perl 6}}==
{{works with|Rakudo|
The fatarrow, <code>=></code>, is no longer just a quoting comma; it now constructs a <code>Pair</code> object. But you can still define a hash with an ordinary list of even length.
Line 1,963:
<lang perl6>my $h = {key1 => 'val1', 'key-2' => 2, three => -238.83, 4 => 'val3'};
say $h<key1>;</lang>
Keys are of type Str or Int by default. The type of the key can be provided.
<lang perl6>
my %hash{Any}; # same as %hash{*}
class C {};
my %cash{C};
%cash{C.new} = 1;</lang>
=={{header|PHP}}==
|