Course of Raku / Essentials / More about types / Typed variables
Type conversion for typed variables
Type constraints are strict enough. For instance, you cannot assign a
Num value, even if it contains a whole integer, to a
variable declared as Int:
my Int $x = 42;
# $x = 42e1; # ErrorUse one of the methods to cast the value.
my Int $x = 42;
$x = 42e1.Int;
$x = Int(42e1);Practice
Complete the quiz that covers the contents of this topic.
Course navigation
← Using
of | Quiz — converting the
types →
💪 Or jump directly to the exercises in this
section.
Translations of this page: English • Deutsch • Español • Italiano • Latviešu • Nederlands • Български • Русский • Українська