From 3556cba5038530e728eb6309dcf5d4d1a96a02ac Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Wed, 24 Jul 2019 10:30:56 -0700 Subject: [PATCH] Document that Range#cover? returns false if <=> returns nil Fixes [Bug #12090] --- range.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/range.c b/range.c index 271c0f2ae9..e8515e0b8a 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 c is non-numeric. * Returns false 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 <=> 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