Content deleted Content added
→Perl 5: copy editing |
copy editing "Raku" subsection (renamed "Perl 6 (Raku)") |
||
Line 1,269:
</syntaxhighlight>
===Perl
[[Raku (programming language)|Perl 6]], renamed as "Raku", also has built-in, language-level support for associative arrays, which are referred to as ''hashes'' or as objects performing the
A hash variable is typically marked by a <code>%</code> [[sigil (computer programming)|sigil]], to visually distinguish it from scalar, array, and other data types, and to define its behaviour towards iteration. A hash literal is a key-value list, with the preferred form using Perl's <code>=></code> token, which makes the key-value association clearer:
<syntaxhighlight lang=Perl6>
Line 1,282:
</syntaxhighlight>
Accessing a hash element uses the syntax <code>%hash_name{$key}</code> – the key is surrounded by
The list of keys and values can be extracted using the built-in functions <code>keys</code> and <code>values</code>, respectively. So, for example, to print all the keys of a hash:
Line 1,292:
</syntaxhighlight>
By default, when iterating
<syntaxhighlight lang=Perl6>
Line 1,300:
</syntaxhighlight>
It
<syntaxhighlight lang=Perl6>
Line 1,308:
</syntaxhighlight>
<syntaxhighlight lang=Perl6>
Line 1,319:
</syntaxhighlight>
<syntaxhighlight lang=Perl6>
|