- Perl 6 Deep Dive
- Andrew Shitov
- 97字
- 2021-07-03 00:05:51
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>;
推薦閱讀
- C# 7 and .NET Core Cookbook
- R語言數據分析從入門到精通
- The Android Game Developer's Handbook
- INSTANT OpenCV Starter
- 數據庫系統原理及MySQL應用教程
- 人人都是網站分析師:從分析師的視角理解網站和解讀數據
- Learning Hunk
- C++新經典
- 詳解MATLAB圖形繪制技術
- R數據科學實戰:工具詳解與案例分析
- Application Development with Parse using iOS SDK
- Java程序設計入門(第2版)
- VMware vSphere Design Essentials
- 川哥教你Spring Boot 2實戰
- Visual FoxPro程序設計