Course of Raku / Advanced / Containers / Subscript adverbs 🆕 / Exercises / Key and value
Solution: Key and value
Here is a possible solution to the task.
Code
my %h = x => 10, y => 20;
say %h<x>:kv;🦋 You can find the source code in the file key-and-value.raku.
Output
(x 10)Comments
The
:kvadverb returns both the key and the value as a list.For a hash, the key is the name you subscript with, so
%h<x>:kvgives the list(x 10).