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

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
主站蜘蛛池模板: 温州市| 沁源县| 光山县| 博乐市| 宁武县| 香港 | 马尔康县| 丰原市| 怀安县| 苏州市| 天气| 米林县| 普安县| 鄢陵县| 子长县| 长垣县| 泰兴市| 扎鲁特旗| 郎溪县| 宜都市| 罗山县| 鹿泉市| 贵港市| 昔阳县| 韶山市| 海城市| 茌平县| 平塘县| 手机| 麻栗坡县| 临沭县| 宜君县| 隆化县| 新乡市| 盐边县| 于田县| 中西区| 栾城县| 长海县| 博客| 邹平县|