- 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
推薦閱讀
- Java逍遙游記
- 多媒體CAI課件設計與制作導論(第二版)
- Learning NServiceBus(Second Edition)
- C#高級編程(第10版) C# 6 & .NET Core 1.0 (.NET開發經典名著)
- 精通JavaScript+jQuery:100%動態網頁設計密碼
- Drupal 8 Blueprints
- PyTorch自動駕駛視覺感知算法實戰
- C語言程序設計基礎與實驗指導
- HTML5 Mobile Development Cookbook
- Bootstrap 4:Responsive Web Design
- PhoneGap:Beginner's Guide(Third Edition)
- Apache Spark 2.x for Java Developers
- 遠方:兩位持續創業者的點滴思考
- Java EE 7 Development with WildFly
- Serverless工程實踐:從入門到進階