- 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
推薦閱讀
- Redis Applied Design Patterns
- 神經網絡編程實戰:Java語言實現(原書第2版)
- INSTANT Sencha Touch
- VSTO開發入門教程
- Python高效開發實戰:Django、Tornado、Flask、Twisted(第2版)
- Cassandra Data Modeling and Analysis
- Haxe Game Development Essentials
- Advanced Oracle PL/SQL Developer's Guide(Second Edition)
- 微服務架構深度解析:原理、實踐與進階
- RealSenseTM互動開發實戰
- Azure Serverless Computing Cookbook
- Windows Phone 8 Game Development
- Data Science Algorithms in a Week
- Python一行流:像專家一樣寫代碼
- C# 7.1 and .NET Core 2.0:Modern Cross-Platform Development(Third Edition)