From: "Stephan Kämper" Date: 2005-01-24T20:15:52+09:00 Subject: Re: Is overloading of the "! operator" possible or not Neulinger Robert (SMS T CARS SW External) wrote: > Hello, > > I'm tying to overload the "! operator", which should be possible due Do you mean "overload" or "override"? You _override_ a method if you change the behaviour of the method in an ancestor (or singleton object). To _overload_ a method means to check the classes/types of the arguments and to use that information to decide which method body to execute. Overloading just doesn't cut the mustard in Ruby; IIRC this has been discussed here before. > to the explanation in the book "Programming ruby" -> The Ruby > Language ->Operator Expressions, > but it's not working. > > On the other hand in the FAQ the ! operator is marked as non-overloadable. > --------------- > http://www.rubycentral.com/faq/rubyfaq-7.html > See section 7.2... > However, the following are built-in control structures, not methods, which > cannot be overridden. > > What is the truth and/or how does it work? > > Thanks for help in advance Robert That should be "override", not "overload" in the FAQ. As I understand the table in the pickaxe (2nd ed. PDF instance, p. 324): tick-mark ! ~ + - Not,complement, unary plus and minus (method names for the last two are +@ and -@) indicates that all these operations may be overridden. Which indeed work for '~', '+' and '-', but not for '!'. At least this is how I understand what Matz posted and what the FAQ states. (The operator group in the pickaxe should probably be split up.) Furthermore I'll go and suggest another 'Q' for the FAQ: A discussion about the difference of overriding and overloading in Ruby. Happy rubying Stephan