Course of Raku / Advanced / Debugging / Debugging with dd / Exercises / Dump a hash

Solution: Dump a hash

Here is a possible solution to the task.

Code

my %h = beta => 2, alpha => 1;
dd %h;

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

Output

{:alpha(1), :beta(2)}

Comments

  1. dd prints the hash in a code-like form, with each pair as :key(value).

  2. The keys come out in sorted order — alpha before beta — even though beta was written first.

Course navigation

Dump a hash   |   Containers