Course of Raku / Advanced / Containers

Subscript adverbs 🆕

When you subscript an array or a hash — @a[2], %h<key> — you can attach an adverb to change what the subscript does. Instead of just fetching the value, you can ask whether a key exists, delete it, or get the key and the value together.

These adverbs are written after the subscript with a colon, and they work the same way on both arrays and hashes. This section covers the most useful ones.

Topics in this section

Practice

Complete the 1 quiz that covers the contents of this section.

Exercises

This section contains 3 exercises. Examine all the topics of this section before doing the coding practice.

  1. Does the key exist
  2. Delete a key
  3. Key and value

Course navigation

Solution: Item or list   |   Exists and delete