If so, is there some magic syntax to define them?
Thanks!
If so, is there some magic syntax to define them?
Thanks!
-= and += are special forms that represent:
y -= x ~> y = y - x
y += x ~> y = y + x
A number of other infix operators can be used in the same way. So these are
not redefinable independent of + and -.
+ and - on the otherhand has two forms, infix and unary. (Unary means prefix
operator.)
Infix
def +(x)
#...
end
def -(x)
#...
end
Unary
def +@
#...
end
def -@
#...
end
HTH,
T
On Friday 12 November 2004 11:13 pm, itsme213 wrote:
If so, is there some magic syntax to define them?
Thanks!
Hi,
On Sat, 13 Nov 2004 13:39:31 +0900, trans. (T. Onoma) <transami@runbox.com> wrote:
On Friday 12 November 2004 11:13 pm, itsme213 wrote:
> If so, is there some magic syntax to define them?
>
> Thanks!-= and += are special forms that represent:
y -= x ~> y = y - x
y += x ~> y = y + xA number of other infix operators can be used in the same way. So these are
not redefinable independent of + and -.+ and - on the otherhand has two forms, infix and unary. (Unary means prefix
operator.)
Also, for a chart of all the operators and details on their
method-ness, look here:
http://phrogz.net/ProgrammingRuby/language.html#operatorexpressions
cheers,
Mark