From: David Flanagan Date: 2008-03-18T13:14:02+09:00 Subject: Re: Range#member? semantics seem wrong Dave Thomas wrote: > Range#member? has been changed so that it the start and end of the range > are scalars, then > > member?(val) is the same as min <= val <= max > > This means that (1..5).member?(3.5) returns true. In 1.8, member meant > that the value was one of the possible elements in the range (so was > effectively the same as range.to.include?(val). > > It seem to me that the old way was more intuitive. We now have three > methods on range (===, include?, and member?) that all do the same > thing, and none allow you to test for membership. > > > > Dave > Actually your sample code also returns true in both 1.8 (at least 1.8.6) and 1.9.0. 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 <=>. David