# +@ and -@ methods?

**URL:** <https://www.ruby-forum.com/t/and-methods/92809>\
**Category:** Ruby\
**Created:** [April 24, 2007, 2:00pm UTC](https://www.ruby-forum.com/t/and-methods/92809 "2007-04-24T14:00:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [April 24, 2007, 2:00pm UTC](https://www.ruby-forum.com/t/and-methods/92809/1 "2007-04-24T14:00:33Z")

</div>

Hi all,

Mostly when I do instance.methods.sort in irb, the list contains +@  
and -@ what are these methods and how used.  
I’ll appreciate if someone helps me with this.

Reagrds  
Gaurav V Bagga

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [April 24, 2007, 2:06pm UTC](https://www.ruby-forum.com/t/and-methods/92809/2 "2007-04-24T14:06:34Z")

</div>

Sorry I forgot to mention  
when I do 1.methods.sort ,Is it something to do with unary operations?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [April 24, 2007, 2:35pm UTC](https://www.ruby-forum.com/t/and-methods/92809/3 "2007-04-24T14:35:43Z")

</div>

Hi,

On 4/24/07, gaurav bagga [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Sorry I forgot to mention  
> when I do 1.methods.sort ,Is it something to do with unary operations?

1 is an object of type Integer

1.methods is a method in the Object Integer (which outputs an Array of  
methods for the integer) and .sort is a method on an Object of Type  
Array (which sorts the contents of the Array)

> On 4/24/07, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Hi all,
> > 
> > Mostly when I do instance.methods.sort in irb, the list contains +@  
> > and -@ what are these methods and how used.  
> > I’ll appreciate if someone helps me with this.

From the pickaxe book +@ is a unary + operator simply returns the  
receivers value and -@ returns the negated value for Numeric Objects  
(floats / Integers)

> –  
> Cheers  
> Gaurav  
> [http://java-n-coffee.blogspot.com](http://java-n-coffee.blogspot.com)  
> [http://rorwebser.blogspot.com](http://rorwebser.blogspot.com)  
> [http://eclipsetrip.blogspot.com](http://eclipsetrip.blogspot.com)

–

à¤…à¤­à¤¿à¤œà¥€à¤¤

[written in [http://www.paahijen.com/scratchpad](http://www.paahijen.com/scratchpad)]

[[http://www.paahijen.com](http://www.paahijen.com)]
