Hi --

On Sun, 13 Aug 2006, Ondrej Bilka wrote:

> On Sun, Aug 13, 2006 at 10:25:03AM +0200, nobu / ruby-lang.org wrote:
>> Hi,
>>
>> At Sun, 13 Aug 2006 15:59:24 +0900,
>> Ondrej Bilka wrote in [ruby-core:08609]:
>>> Problem of discrete membership at Range#=== is that it returns unexpected
>>> result when treating float-like Classes. Class Time is represented as
>>> float so
>>> (Time.new...Time.new+5)===Time.new returns false.
>>
>> Really?
>>
>> $ ruby -ve 't = Time.new; p((t...t+5)===t+1)'
>> ruby 1.9.0 (2006-08-12) [i686-linux]
>> true
>>
>> And Time isn't float.
>>
>>> I choose Comparable#between? but I rather change its
>>> arguments to low.between?(value, high,excl) because now value
>>> doesnt know what range represents and can only guess that
>>> they are same type.(I dont know how frequently its used. )
>>
>> Double dispatch may be considerable, but that change of
>> "between?" feels doubtful to me.
>>
>> --
>> Nobu Nakada
>>
> Can someone simply cut my text and paste it???

irb(main):010:0> (Time.new...Time.new+5)===Time.new
=> true
irb(main):011:0> RUBY_VERSION
=> "1.8.4"

> If you are lazy try
> t=Time.new
> (t...t+5.5)===t+2.3
> which return false too

irb(main):012:0> t = Time.new
=> Sun Aug 13 06:34:02 EDT 2006
irb(main):013:0> (t...t+5.5)===t+2.3
=> true


David

-- 
http://www.rubypowerandlight.com => Ruby/Rails training & consultancy
   ----> SEE SPECIAL DEAL FOR RUBY/RAILS USERS GROUPS! <-----
http://dablog.rubypal.com        => D[avid ]A[. ]B[lack's][ Web]log
http://www.manning.com/black     => book, Ruby for Rails
http://www.rubycentral.org       => Ruby Central, Inc.