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

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
主站蜘蛛池模板: 乌拉特后旗| 武穴市| 聂荣县| 格尔木市| 应用必备| 南部县| 合川市| 璧山县| 林州市| 万荣县| 石棉县| 桐城市| 深水埗区| 上林县| 台安县| 平乐县| 寻乌县| 泰兴市| 镇巴县| 西丰县| 景谷| 迁安市| 万宁市| 阳泉市| 中卫市| 武平县| 横山县| 万安县| 东丽区| 碌曲县| 西乌| 班戈县| 宝山区| 芮城县| 礼泉县| 连南| 儋州市| 麻栗坡县| 寿阳县| 鄢陵县| 临夏县|