summaryrefslogtreecommitdiff
path: root/range.c
diff options
context:
space:
mode:
authorTanaka Akira <[email protected]>2023-10-13 00:00:58 +0900
committerTanaka Akira <[email protected]>2023-10-13 00:00:58 +0900
commitc23b25f75f6180b7428f9650e063b1e50fc161e2 (patch)
treef4983a22426410499e2e3ef2be4bfe162a6ee098 /range.c
parentb2e1ddffa55463f1180af7f9b269a2d89140b131 (diff)
describe the assumption for Range#overlap?.
Range#overlap? assumes that there is no minimum value. This assumption makes +(...-Float::INFINITY).overlap?((...-Float::INFINITY))+ returns true while +(...-Float::INFINITY)+ is empty.
Diffstat (limited to 'range.c')
-rw-r--r--range.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/range.c b/range.c
index 867c96336a..7e72984dc7 100644
--- a/range.c
+++ b/range.c
@@ -2386,6 +2386,19 @@ empty_region_p(VALUE beg, VALUE end, int excl)
* (1..2).overlap?(3..4) # => false
* (1...3).overlap?(3..4) # => false
*
+ * This method assumes that there is no minimum value because
+ * Ruby lacks a standard method for determining minimum values.
+ * This assumption is invalid.
+ * For example, there is no value smaller than +-Float::INFINITY+,
+ * making +(...-Float::INFINITY)+ an empty set.
+ * Consequently, +(...-Float::INFINITY)+ has no elements in common with itself,
+ * yet +(...-Float::INFINITY).overlap?((...-Float::INFINITY))+ returns
+ * true due to this assumption.
+ * In general, if +r = (...minimum); r.overlap?(r)+ returns +true+,
+ * where +minimum+ is a value that no value is smaller than.
+ * Such values include +-Float::INFINITY+, +[]+, +""+, and
+ * classes without subclasses.
+ *
* Related: Range#cover?.
*/