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

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>;
主站蜘蛛池模板: 盐边县| 五峰| 栾城县| 泰宁县| 佛教| 夏津县| 黎城县| 简阳市| 上高县| 榆林市| 冷水江市| 肥西县| 崇文区| 兴和县| 石台县| 临洮县| 浦江县| 梓潼县| 阿荣旗| 松阳县| 永川市| 大城县| 平阳县| 许昌市| 合作市| 江城| 勃利县| 宁津县| 廊坊市| 屯留县| 华亭县| 苗栗市| 宜兰市| 兰坪| 陆川县| 青州市| 闽侯县| 彭水| 云龙县| 龙川县| 乌兰浩特市|