Course of Raku / Essentials / More about types / Typed variables / Type conversion for typed variables

Quiz — converting the types

Select the allowed assignments in Raku.

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

Course navigation

Type conversion for typed variables   |   Allomorphs

Translations of this page: EnglishDeutschEspañolItalianoLatviešuNederlandsБългарскиРусскийУкраїнська