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

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>;
主站蜘蛛池模板: 琼中| 黄骅市| 融水| 横山县| 铜鼓县| 枣强县| 阿坝县| 吴旗县| 黑龙江省| 紫云| 阿鲁科尔沁旗| 富源县| 大城县| 五寨县| 河北省| 苗栗市| 赤城县| 桑日县| 资源县| 嘉祥县| 全椒县| 馆陶县| 青河县| 麻城市| 延庆县| 上林县| 延寿县| 田阳县| 商都县| 横山县| 甘南县| 平果县| 西宁市| 罗源县| 万山特区| 呼玛县| 仙桃市| 措美县| 洛浦县| 延吉市| 和硕县|