From: Shannon Fang Date: 2002-12-07T07:18:23+09:00 Subject: Re: YA ++ explanation The reason I am considering this is I try to understand how operator overload work in ruby, could anyone tell me a list of all operators that I can overload in ruby? Tks... Shannon On Sat, 7 Dec 2002 07:12:27 +0900 Mauricio Fern~{an~}dez wrote: > On Sat, Dec 07, 2002 at 06:39:56AM +0900, Nat Pryce wrote: > > From: "Shannon Fang" > > > Any comments? Since everything in ruby is object, += is a method of the > > > object preceding it, why can't ++ like that? > > > > The operator += is not a method in Ruby. The parser treats += in a special > > way. Specifically, it treats: > > > > a += x > > > > As an alias for: > > > > a = a + x > > > > In that form, the + operator is a method call on the object refered to by > > 'a' with the object refered to by 'b' as the parameter. The '=' is an > > assignment to a local variable 'a', and is handled in a special way by the > > language. > > I think he had 'succ!' in his mind. > > -- > _ _ > | |__ __ _| |_ ___ _ __ ___ __ _ _ __ > | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ > | |_) | (_| | |_\__ \ | | | | | (_| | | | | > |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| > Running Debian GNU/Linux Sid (unstable) > batsman dot geo at yahoo dot com > > ..Deep Hack Mode -- that mysterious and frightening state of > consciousness where Mortal Users fear to tread. > -- Matt Welsh