Project

General

Profile

Actions

Bug #19864

closed

Ruby 3.2 Changed Behavior With One Sided Ranges

Added by Aesthetikx (John DeSilva) about 1 year ago. Updated about 1 year ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:114641]

Description

Thank you for taking the time to read my issue. I know there has been some previous discussion here https://bugs.ruby-lang.org/issues/19533 regarding a similar issue, although I think this is different. I apologize if this has already been addressed.

Prior to Ruby 3.2, you could use a beginless or endless range, and use === (or a case statement) to determine if a given date matched that range. For example, (..today) === yesterday would have returned true, and (tomorrow..) === today would have returned false. Please see my attached file for a more concrete example.

Starting with Ruby 3.2, this results in "`===': cannot determine inclusion in beginless/endless ranges (TypeError)".

I can imagine that there is difficulty and ambiguity with these infinite ranges and non numeric objects, however I do feel that these examples with dates should work, especially since (..Date.today).cover?(Date.today) still works as expected.


Files

range_test.rb (928 Bytes) range_test.rb Aesthetikx (John DeSilva), 09/05/2023 09:32 PM
range_test_2.rb (411 Bytes) range_test_2.rb jgomo3 (Jesús Gómez), 09/06/2023 12:17 PM
range_test_3.rb (162 Bytes) range_test_3.rb jgomo3 (Jesús Gómez), 09/06/2023 12:17 PM
Actions

Also available in: Atom PDF

Like2
Like0Like0Like0Like2Like0Like1Like0