Course of Raku / Essentials / Associative data types / Interpolating hashes
Quiz — Interpolating hashes
Given the following hash:
my %letters = α => 'Alpha', β => 'Beta', γ => 'Gamma';
Complete the below programs to get the requested output.
1
Using the hash, print the name of the Greek letter β
. Use the form without quotes around the key string.
<β> | say "The letter β is called %letters␣␣."; |
2
Using the hash, print the name of the Greek letter β
. Use the form where the key is quoted in single quotes.
{'β'} | say "The letter β is called %letters␣␣␣␣."; |
3
Print the letters and their names as a table.
letters{ | say "Here are some Greek letters:\n%␣␣␣␣␣}\netc."; | Note that the output may be not sorted. |
The possible output for this case is:
Here are some Greek letters:
α Alpha
β Beta
γ Gamma
etc.
Course navigation
← Associative data types / Nested hashes | 💪 Exercises: Associative data types →
Translations of this page: English • Deutsch • Español • Italiano • Latviešu • Nederlands • Български • Русский • Українська