[ruby-core:117862] [Ruby master Bug#20487] 1..nil is giving range from 1 to inifinity in ruby greater than 2.6
From:
"akshay_kakade (Akshay Kakade) via ruby-core" <ruby-core@...>
Date:
2024-05-13 12:18:01 UTC
List:
ruby-core #117862
Issue #20487 has been reported by akshay_kakade (Akshay Kakade).
----------------------------------------
Bug #20487: 1..nil is giving range from 1 to inifinity in ruby greater than 2.6
https://bugs.ruby-lang.org/issues/20487
* Author: akshay_kakade (Akshay Kakade)
* Status: Open
* ruby -v: 3.2.0
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
we consider nil as undefined value, value that is not present, we consider nil as falsey value as well, when we do nil.to_i it gives us zero..then with this rational 1..nil shouldn't give the range 1 to infinity, either we should make it as invalid or it should be converted to 1..0
script:
(1..nil).each {|n| puts n }
output
1
2
3
4
5
6
7
.
.
.
.
infinity
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/