On Friday 12 December 2003 04:06 am, dhtapp wrote:
> "T. Onoma" <transami / runbox.com> wrote in message
> news:200312111731.02127.transami / runbox.com...
>
> > Oops, my bad, wrong mailing list. Please see fowared message:
> >
> > As for +@: -@ works fine but +@ acts as if it doesn't exist unless one
>
> uses
>
> > paraethesis.
>
> Could someone take a quick minute to explain what this syntax is used for?
>
> Thanks!

Hi, dan

+@ and -@ are used to define unary operators for + (plus) and - (minus). It is 
a special notation so that ruby knows what you're are talking about. Consider 
that when you put a minus sign in front of a number you are actually calling 
the -@ method of the Numeric class. For example, if your were defining it 
yourself you would do it something like this:

class Numeric

  def -@
    return self * -1
  end

end

As far as I know -@ and +@ are the only unary operators that can be defined.

HTH, 
T.