Course of Raku / Advanced / Operators / Types of Raku operators / Exercises / Subscript a hash

Solution: Subscript a hash

Here is a possible solution to the task.

Code

my %h = a => 1;
say %h<a>;

🦋 You can find the source code in the file subscript-a-hash.raku.

Output

1

Comments

  1. The < > subscript is a postcircumfix operator: it follows a term (the hash) and surrounds the key.

  2. %h<a> returns the value stored under the key a, which is 1.

Course navigation

Subscript a hash   |   Quiz — Operator categories