官术网_书友最值得收藏!

Converting to an Int value

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>;
主站蜘蛛池模板: 繁峙县| 沙雅县| 景德镇市| 祁连县| 波密县| 璧山县| 吴江市| 汉川市| 军事| 邵阳县| 资中县| 广安市| 兴业县| 昆明市| 南木林县| 乐陵市| 灌南县| 连山| 彭阳县| 六盘水市| 固始县| 虎林市| 泊头市| 绥江县| 开封县| 翁牛特旗| 大安市| 徐闻县| 建湖县| 昌平区| 万宁市| 勃利县| 萨嘎县| 邹城市| 云龙县| 交口县| 漳州市| 武汉市| 凯里市| 峨边| 合肥市|