From: ptkwt@...1.aracnet.com (Phil Tomson) Date: 2002-02-23T07:40:35+09:00 Subject: Re: overriding operator 'or' In article , Phil Tomson wrote: >According to "Ruby in a Nutshell" pg 18, 'or' is a nonmethod operator >which cannot be overridden. However, it seems that I CAN override the >'or' operator: > >irb(main):001:0> class Foo >irb(main):002:1> def initialize(value) >irb(main):003:2> @value = value >irb(main):004:2> end >irb(main):005:1> def or(other) >irb(main):006:2> @value or other >irb(main):007:2> end >irb(main):008:1> end >nil >irb(main):009:0> myfoo = Foo.new(1) ># >irb(main):012:0> p myfoo or 0 ># >0 > A little more investigation reveals that 'or' was not really overridden in the code above. The original 'or' is still being called. Phil