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

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.

主站蜘蛛池模板: 郧西县| 北川| 平定县| 云梦县| 福建省| 墨脱县| 永州市| 兴城市| 二连浩特市| 东平县| 兰考县| 肃北| 斗六市| 庐江县| 舟曲县| 普兰店市| 星子县| 犍为县| 安溪县| 贡山| 邵东县| 定兴县| 沈丘县| 中西区| 灵璧县| 南靖县| 墨竹工卡县| 衡东县| 广昌县| 惠安县| 义乌市| 砀山县| 巍山| 桃园县| 汾西县| 安吉县| 嘉兴市| 益阳市| 马尔康县| 长武县| 湘潭县|