Course of Raku / Advanced /
Control flow / given and when
/ Exercises
Match by type
Problem
A when can match against a type, not just a
value. Given the number 3.14 stored in a variable, use
given/when to report what kind of value it is:
print integer for an Int,
rational for a Rat, and string
for a Str.
Example
The program prints:
rational