- 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>;
推薦閱讀
- Learning Neo4j
- 編寫高質量代碼:改善C程序代碼的125個建議
- SQL Server 2016數據庫應用與開發習題解答與上機指導
- Swift語言實戰精講
- Swift細致入門與最佳實踐
- SQL 經典實例
- iOS開發項目化入門教程
- Android移動應用項目化教程
- UML基礎與Rose建模實用教程(第三版)
- Python高性能編程(第2版)
- CryENGINE Game Programming with C++,C#,and Lua
- 深入大型數據集:并行與分布化Python代碼
- 從零開始學UI設計·基礎篇
- React.js實戰
- ASP.NET Core 2 High Performance(Second Edition)