> So the @-sign in Ruby is like self in Python? Can someone confirm who
> knows Python?

Not so much. Much like Python=2C Ruby classes deal with self as well. Howev=
er in Ruby that's passed around behind the scenes=2C so you won't see it in=
 method definitions. Take for example the following:

--------------------------------------
>>> class Test:
...=A0=A0 myvar =3D "This is a variable"
...=A0=A0 def mymethod(self):
...=A0=A0=A0=A0 return self.myvar
...=20
>>> inst =3D Test()
>>> inst.mymethod()
'This is a variable'
--------------------------------------

Here in this case=2C the instance of Test=2C `inst` is being passed in as "=
self" to mymethod. Now something to note is that here:

------------------------------------
myvar =3D "This is a variable"
------------------------------------

Has the same `self` as=20

------------------------------------
return self.myvar
------------------------------------

Now in Ruby=2C things are different. When defining classes=2C self inside t=
he class definition can be referring to two different things. Take for exam=
ple a copy of the above:

------------------------------------
irb(main):001:0> class Test
irb(main):002:1>=A0=A0 @myvar =3D "This is a variable"
irb(main):003:1>=A0=A0 def mymethod
irb(main):004:2>=A0=A0=A0=A0=A0 @myvar
irb(main):005:2>=A0=A0 end
irb(main):006:1> end
=3D> nil
irb(main):007:0> inst =3D Test.new
=3D> #<Test:0x0000010202eb00>
irb(main):008:0> inst.mymethod
=3D> nil
irb(main):009:0>
------------------------------------

Noticed that mymethod returned nil. This is because `self` in the context o=
f where @myvar is located is the CLASS ITSELF:

------------------------------------
irb(main):009:0> class Test
irb(main):010:1>=A0=A0 p self
irb(main):011:1>=A0=A0 @myvar =3D "This is a variable"
irb(main):012:1>=A0=A0 def mymethod
irb(main):013:2>=A0=A0=A0=A0 @myvar
irb(main):014:2>=A0=A0 end
irb(main):015:1> end
Test
=3D> nil
-----------------------------------

That is because class definitions in Ruby are expressions that evaluate to =
the last statement of the class definition. In this case method definitions=
 return nil=2C so that's the resulting value. We could change this however:

-----------------------------------
irb(main):018:0> class Test
irb(main):019:1>=A0=A0 @myvar =3D "This is a variable"
irb(main):020:1>=A0=A0 def mymethod
irb(main):021:2>=A0=A0=A0=A0 @myvar
irb(main):022:2>=A0=A0 end
irb(main):023:1>=A0=A0 "return value"
irb(main):024:1> end
=3D> "return value"
-----------------------------------

Notice how in this case=2C a string value is the last statement=2C so that =
string becomes the result of the class definition. Now when we were calling=
 mymethod from an instance=2C the instance itself is passed in to mymethod =
instead. This is a crucial difference between Ruby and Python in how classe=
s are defined. If at any time you get confused as to how methods/variables =
are being accessed=2C check the value of self.

Regards=2C
Chris White
http://www.twitter.com/cwgem
 		 	   		  =