提交 28b008ba 编写于 作者: J José Valim

Merge pull request #4197 from nashby/refactor-range-include

refactor Range#include? for range value
......@@ -9,9 +9,7 @@ class Range
# (5..9).include?(11) # => false
def include_with_range?(value)
if value.is_a?(::Range)
operator = exclude_end? ? :< : :<=
end_value = value.exclude_end? ? last.succ : last
include_without_range?(value.first) && (value.last <=> end_value).send(operator, 0)
min <= value.min && max >= value.max
else
include_without_range?(value)
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册