From: Dave Thomas Date: 2008-03-18T22:44:26+09:00 Subject: Re: Range#member? semantics seem wrong On Mar 17, 2008, at 11:14 PM, David Flanagan wrote: > Actually your sample code also returns true in both 1.8 (at least > 1.8.6) and 1.9.0. Checking, I agree. I wonder if this is a change since an earlier 1.8. > And 1.9.0 has also introduced a new method named cover?. > > My understanding (and it takes me all of page 70 to explain this in > my book) is that in 1.9 include? and member? test what I call > "discrete membership" (and what you call membership) using succ when > the endpoints of the range are not numbers. For numbers they test > continuous membership using <=>. And the new method cover? always > uses the continuous membership test using <=>. I use membership in the 'set' sense. And there doesn't seem to be a way of determining whether the range of integers (1..3) contains 2 (set membership) but not 2.5 (range inclusion). And that seems unfortunate. I'd like to see member? do what it's name suggests and work on a set-like basis, so that (1..3).member?(2) => true (1..3).member?(2.5) => false Dave