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

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.

主站蜘蛛池模板: 安乡县| 黑山县| 黄冈市| 仙居县| 阜新| 醴陵市| 朔州市| 沙洋县| 托克逊县| 夏邑县| 苗栗市| 安福县| 隆子县| 民勤县| 九龙坡区| 托克逊县| 馆陶县| 山阳县| 楚雄市| 砚山县| 班戈县| 丰都县| 都昌县| 松阳县| 凤城市| 尼勒克县| 景洪市| 建宁县| 南开区| 扬中市| 晋州市| 青铜峡市| 甘肃省| 盐亭县| 基隆市| 绥阳县| 漳平市| 汽车| 崇礼县| 岗巴县| 龙井市|