Project

General

Profile

Actions

Bug #18577

closed

Range#include? returns wrong result for beginless range with exclusive string end

Added by takaram (Takuya Aramaki) almost 3 years ago. Updated almost 3 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x86_64-linux]
[ruby-core:107521]

Description

Exclusive range should not include the end value, but (...'z').include? 'z' returns true. member? and === behave in the same way, while cover? does not.
This happens when the range is beginless and its end is string.

irb(main):001:0> (...'z').include? 'z'
=> true
irb(main):002:0> (...'z').member? 'z'
=> true
irb(main):003:0> (...'z') === 'z'
=> true
irb(main):004:0> (...'z').cover? 'z'
=> false
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0