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

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>;
主站蜘蛛池模板: 萝北县| 西青区| 仁化县| 遂平县| 瑞昌市| 荃湾区| 博罗县| 桂平市| 铜鼓县| 富蕴县| 许昌市| 霸州市| 武城县| 双鸭山市| 肥东县| 新兴县| 新河县| 衡山县| 高雄市| 永宁县| 元江| 图片| 苍山县| 樟树市| 黑山县| 桦川县| 昌邑市| 凌云县| 姚安县| 广丰县| 顺昌县| 彭泽县| 平邑县| 塘沽区| 东乡族自治县| 皋兰县| 斗六市| 炉霍县| 当阳市| 德令哈市| 建始县|