From: rosskaff@... Date: 2016-01-18T22:13:24+00:00 Subject: [ruby-core:72908] [Ruby trunk - Bug #12003] [Open] Unexpected behavior of === with Range of Date objects Issue #12003 has been reported by Ross Kaffenberger. ---------------------------------------- Bug #12003: Unexpected behavior of === with Range of Date objects https://bugs.ruby-lang.org/issues/12003 * Author: Ross Kaffenberger * Status: Open * Priority: Normal * Assignee: * ruby -v: * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- In Ruby 2.2, a Range of Date objects will return true when matched with === for a new Date that falls in the range: ~~~ puts ENV['RUBY_VERSION'] # => '2.2.3' require 'date' date_range = Date.new(1980, 1, 1)..Date.new(1990, 1, 10) # => #..# puts date_range.cover? Date.new(1989, 10, 13) # => true puts date_range === Date.new(1989, 10, 13) # => true ~~~ In Ruby 2.3.0, === returns false for the same date and date range: ~~~ puts ENV['RUBY_VERSION'] # => '2.3.0' require 'date' date_range = Date.new(1980, 1, 1)..Date.new(1990, 1, 10) # => #..# puts date_range.cover? Date.new(1989, 10, 13) # => true puts date_range === Date.new(1989, 10, 13) # => false ~~~ In both Ruby 2.2.3 and Ruby 2.3.0, date comparisons with === return true, i.e, Date.new(1980, 1, 1) === Date.new(1980, 1, 1) # => true. I believe this may be a regression in the === implementation of Range. -- https://bugs.ruby-lang.org/ Unsubscribe: