- 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
推薦閱讀
- Learning Java Functional Programming
- Software Defined Networking with OpenFlow
- PHP 7底層設計與源碼實現
- 實戰Java程序設計
- Django:Web Development with Python
- Effective Python Penetration Testing
- Mastering Rust
- Python:Master the Art of Design Patterns
- R Data Analysis Cookbook(Second Edition)
- Oracle Database 12c DBA官方手冊(第8版)
- 現代JavaScript編程:經典范例與實踐技巧
- Expert Cube Development with SSAS Multidimensional Models
- HTML5+CSS3+JavaScript案例實戰
- Instant MongoDB
- VLSI設計基礎