Course of Raku / Advanced / More about built-in types / Sets, bags, and mixes / Set operations
Quiz — Sets
What does the following program print?
say (set(1, 2) ∪ set(2, 3)).elems;| 1 | 3 |
| 0 | 4 |
| 0 | 2 |
| 0 | 1 |
The union collects every value from either set, but a set keeps each
value only once. The two sets share 2, so the union is
{1, 2, 3} — three distinct elements.
Course navigation
← Set operations | Bags and mixes →