On 8/17/06, Henry Savr <hsavr / yahoo.com> wrote:
> It's new behaviour should be like this:
>
> class Time1 < Time
>   def >(other)
>     case other.class.name
>         when "Time"
>                 return self > other # but use the OLD > method definition.
>         when ("NilClass")
>                 return true
>         else
>               # do what Ruby does originally in this case : when one operand is
> Time, and other not the Time.
>         end
> end

Unrelated hat tip: many classes define the #=== method, for "case
equality", and it's used in case statements. Your code could be
simplified to

  case other
    when Time
      self > other
    when NilClass
      true
    end


>
> So question was
> 1. How to instruct Ruby to use OLD definition?
> 2.      a)What Ruby does if it sees one parameter of Time class and other
> non-Time?
>         b)How to say him to do the same?
> Thank you
>
> Henry
>
> --
> Posted via http://www.ruby-forum.com/.
>
>


-- 
- Simen