有没有一种优雅的方法来排除范围的第一个值? [英] Is there an elegant way to exclude the first value of a range?
本文介绍了有没有一种优雅的方法来排除范围的第一个值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有一个从 0 到 10 的范围:
Let's say I have a range from 0 to 10:
range = 0...10
三个点表示排除最后一个值 (10):
Three dots mean, that the last value (10) is excluded:
range.include? 10
=> false
现在,是否有类似且优雅的方法来排除 first 值?
对于上面的例子,这意味着包括所有更大的值(>
,not >=
) 小于 0 并且小于小于 10.
Now, is there a similar and elegant way to exclude the first value?
For the above example, this would mean to include all values that are bigger (>
, not >=
) than 0 and smaller than 10.
推荐答案
没有
((0+1)..10)
这篇关于有没有一种优雅的方法来排除范围的第一个值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文