Skip to content

Commit

Permalink
adds a comments that clarifies why Range#include? chooses the compari…
Browse files Browse the repository at this point in the history
…son operator
  • Loading branch information
fxn committed Dec 30, 2011
1 parent edfe7d8 commit 9fa59ca
Showing 1 changed file with 1 addition and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Range
# (5..9).include?(11) # => false
def include_with_range?(value)
if value.is_a?(::Range)
# 1...10 includes 1..9 but it does not include 1..10.
operator = exclude_end? && !value.exclude_end? ? :< : :<=
include_without_range?(value.first) && value.last.send(operator, last)
else
Expand Down

0 comments on commit 9fa59ca

Please sign in to comment.