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

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>;
主站蜘蛛池模板: 罗江县| 宁国市| 红安县| 邹城市| 锡林浩特市| 乌兰浩特市| 柞水县| 上高县| 鹤庆县| 盈江县| 抚州市| 清涧县| 济南市| 开原市| 扎囊县| 宜昌市| 南丹县| 涞源县| 曲阜市| 崇文区| 淅川县| 天全县| 海安县| 太白县| 泗阳县| 旺苍县| 赞皇县| 合肥市| 宜宾县| 三穗县| 工布江达县| 平利县| 奎屯市| 武邑县| 达拉特旗| 东山县| 五大连池市| 新乡县| 灌云县| 大田县| 胶南市|