September 2017
Beginner
402 pages
9h 52m
English
To convert the Rat value to an integer value, call the Int method. This is the general principle for type conversion: data types define the methods whose names repeat the names of other data classes.
my $x = 10/3;say $x.Int; # 3
In this program, the result of $x.Int is 3, but you should keep in mind that 10/3 in the assignment is not a division, but a way to express a Rat number. The same can be done using a more explicit form, as shown here:
my $x = <10/3>;
Read now
Unlock full access