- Perl 6 Deep Dive
- Andrew Shitov
- 74字
- 2021-07-03 00:05:50
Getting the absolute value
The abs method returns the absolute value. In the following example, the method is called on a variable:
my $x = -42;
say $x.abs; # 42
To call it on a value, parentheses are needed for negative values. Otherwise, the unary minus operator (see more in Chapter 4, Working with Operators) will be applied to the result of calling the abs method:
say (-42).abs; # 42
say -42.abs; # -42
推薦閱讀
- 大話PLC(輕松動漫版)
- SPSS數(shù)據(jù)挖掘與案例分析應(yīng)用實踐
- 微服務(wù)與事件驅(qū)動架構(gòu)
- 前端跨界開發(fā)指南:JavaScript工具庫原理解析與實戰(zhàn)
- Mastering phpMyAdmin 3.4 for Effective MySQL Management
- 深度學(xué)習(xí):算法入門與Keras編程實踐
- Microsoft System Center Orchestrator 2012 R2 Essentials
- SQL Server從入門到精通(第3版)
- Access 2010數(shù)據(jù)庫應(yīng)用技術(shù)(第2版)
- Python機器學(xué)習(xí)算法: 原理、實現(xiàn)與案例
- 詳解MATLAB圖形繪制技術(shù)
- Scratch3.0趣味編程動手玩:比賽訓(xùn)練營
- Python從入門到精通(第3版)
- Webpack實戰(zhàn):入門、進階與調(diào)優(yōu)(第2版)
- Apache Solr PHP Integration