Course of Raku / Essentials / Typed variables / Type conversion for typed variables

Quiz — converting the types

Select the allowed assignments in Raku.

1 my Int $a = π.Int;  
0 my Int $b = π; π is Num, so it cannot be directly assigned to an Int.
0 my Rat $c = π.Int; Even if π.Int is 3 and is of a ‘narrower’ type than Rat, it is not possible to assign.
1 my Rat $d = π.Str.Rat; Double type conversion, just for fun, there’s no particular sense in it, but it is legal.
0 my Num $e = π.Int;  
1 my Num $f = π.Int.Str.Num;  

Course navigation

Typed variables / Using of   |   Typed variables / Allomorphs

💪 Or jump directly to the exercises to this section.