From: Austin Ziegler Date: 2002-07-03T22:01:53+09:00 Subject: Re: (0..3) == (0...4) returning false? On Wed, 3 Jul 2002 18:13:52 +0900, David Alan Black wrote: > On Wed, 3 Jul 2002, Yukihiro Matsumoto wrote: >> on 02/07/03, "Juergen Katins" writes: >>> Although (0...4) === 3.2 produces true (which means 3.2 is >>> included in (0...4) ) 3.2 is no element of (0...4) in terms of >>> (0...4).each (which means 3.2 is NOT included in (0...4) ). It >>> is a little bit illogical. Look out! >> I'm working on it in 1.7, but still no firm decision. If you have >> any comment, proposal, and idea, tell me freely. > My instinct would be to expect: > > aRange === n iff aRange.to_a.include?(n) > > (which probably ends up being the same as Juergen's #each test) I think that your test would result, however, in (0..3) == (0...4) and I'm not sure that's good. Although I haven't yet had a need to use ranges in this way, I actually think that the current behaviour is proper such that each covers the whole numbers. I might consider a variation on each for ranges to be nice: (0...4).each(0.5) { |x| print "#{x}, " } # => 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, It'd be nicer if you could specify the step as part of the creation of the range, but I'm really not sure how you'd do that. -austin -- Austin Ziegler, austin@halostatue.ca on 2002.07.03 at 08.56.13