Course of Raku / Essentials / More about types / Typed variables / Type constraints

Quiz — Type constraints

Make the variables in the below program type-restricted. Choose the most narrow type required to keep the value;

Intmy ␣␣␣ $a = 500;
Intmy ␣␣␣ $b = 304839573985398539853535353;Long numbers are supported out of the box.
Ratmy ␣␣␣ $c = 3.5;This is a Rat. Note that Num values are written in scientific notation.
Ratmy ␣␣␣ $d = 17/19;This is also a Rat, and not a division.
Ratmy ␣␣␣ $e = <2/5>;This is one of the possible notations for Rats.
Nummy ␣␣␣ $f = pi;The built-in value of π is a Num value.
Nummy ␣␣␣ $g = 3e-4;
Strmy ␣␣␣ $h = '18';

Course navigation

Type constraints   |   Using of

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