From: David Alan Black Date: 2000-12-23T08:37:40+09:00 Subject: [ruby-talk:7983] Re: Naming of "defined?" On Sat, 23 Dec 2000, Dave Thomas wrote: > "Guy N. Hurst" writes: > > > I had a problem on page 221 of Programming Ruby, > > where it indicates that "defined?" is a method... Dave, > > could you explain? (Maybe I should have said something sooner) > > You think _you_ had a problem on page 221 ;-) > > Actually, that's a bug. Maybe. We _call_ it an operator consistently, > and the tick in the method column says that it can be overridden. > That's only half true. You _can_ override it, but you can't easily > _use_ the new method: > > def defined?(a) > puts "new" > end > puts defined?(1) #=> "expression" > public :defined? > puts self.defined?(1) #=> new > > So I'm not sure what to do: shall we remove the tick or not? > > > Confused of Dallas > It seems more like an co-ride than an override, at least taking the latter term in a possibly sub-rigorous, semi-intuitive sense. You can certainly do similar things with other things that are not "ticked off" on p. 221: irb(main):001:0> def not irb(main):002:1> puts "No way" irb(main):003:1> end nil irb(main):004:0> public :not Object irb(main):005:0> self.not No way nil irb(main):006:0> not 3 false irb(main):007:0> ... so I'm not sure what defined?'s tick has going for it. David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav