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

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
主站蜘蛛池模板: 马公市| 阿瓦提县| 讷河市| 华亭县| 汕尾市| 鄂伦春自治旗| 清涧县| 亳州市| 越西县| 韩城市| 酒泉市| 霍邱县| 永顺县| 乐山市| 五家渠市| 温州市| 英德市| 新邵县| 鄱阳县| 虎林市| 富裕县| 静宁县| 五家渠市| 铁岭县| 句容市| 武穴市| 德化县| 庐江县| 五常市| 阜康市| 永城市| 浦东新区| 怀安县| 昆明市| 东宁县| 松潘县| 连城县| 泾阳县| 瑞昌市| 迭部县| 中山市|