summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-07-24 10:30:56 -0700
committerJeremy Evans <code@jeremyevans.net>2019-07-24 10:35:28 -0700
commit3556cba5038530e728eb6309dcf5d4d1a96a02ac (patch)
tree727f5d879713783e6f60228a867f3f5ff0a17aa4
parent1cce4303247110d94eab8326f187a2a80130b324 (diff)
Document that Range#cover? returns false if <=> returns nil
Fixes [Bug #12090]
-rw-r--r--range.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/range.c b/range.c
index 271c0f2ae9e..e8515e0b8ae 100644
--- a/range.c
+++ b/range.c
@@ -1455,11 +1455,14 @@ static int r_cover_range_p(VALUE range, VALUE beg, VALUE end, VALUE val);
* the end of the sequence must be calculated, which may exhibit poor
* performance if <code>c</code> is non-numeric.
* Returns <code>false</code> if the begin value of the
- * range is larger than the end value.
+ * range is larger than the end value. Also returns +false+ if one of the
+ * internal calls to <code><=></code> returns +nil+ (indicating the objects
+ * are not comparable).
*
* ("a".."z").cover?("c") #=> true
* ("a".."z").cover?("5") #=> false
* ("a".."z").cover?("cc") #=> true
+ * ("a".."z").cover?(1) #=> false
* (1..5).cover?(2..3) #=> true
* (1..5).cover?(0..6) #=> false
* (1..5).cover?(1...6) #=> true