官术网_书友最值得收藏!

  • 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
主站蜘蛛池模板: 绩溪县| 扎囊县| 天长市| 西华县| 逊克县| 宁蒗| 易门县| 万州区| 江源县| 苍溪县| 霸州市| 金阳县| 南安市| 梓潼县| 乌拉特中旗| 衡水市| 吉安县| 吴忠市| 深圳市| 福鼎市| 息烽县| 富宁县| 五家渠市| 丽水市| 永济市| 连平县| 黄冈市| 上思县| 青神县| 宜城市| 武鸣县| 吉安市| 盐城市| 罗源县| 富阳市| 泸水县| 嘉祥县| 封开县| 通江县| 汉川市| 巴东县|