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

Getting the next and previous values

The two methods, pred and succ, correspondingly return the previous and the next values for integer arguments:

say 42.pred; # 41
say 42.succ; # 43

This method also works with non-integer values, when they add or subtract 1, as shown in the next fragment: 

say pi.pred;    # 2.14159265358979
say (3/4).succ; # 1.75

The names of the methods come from the words predecessor and successor.

主站蜘蛛池模板: 惠东县| 宁远县| 来凤县| 文昌市| 黄梅县| 永吉县| 鹿泉市| 津市市| 湟中县| 阳春市| 南陵县| 铁力市| 阿拉善左旗| 托克逊县| 昭通市| 清原| 公安县| 靖边县| 汉寿县| 西安市| 峨边| 南通市| 渝中区| 东城区| 寿宁县| 清流县| 清新县| 南江县| 长垣县| 金沙县| 泌阳县| 汝州市| 上蔡县| 蒲城县| 定安县| 枞阳县| 太原市| 镇沅| 故城县| 六盘水市| 双流县|