From: Michal Gabrukiewicz Date: 2007-12-01T00:04:10+09:00 Subject: Re: problem with 'self'. behaves different on setting and ge thanks jari ... i can see clearly now :) Jari Williamsson wrote: > Michal Gabrukiewicz wrote: > >> so my 1st question is: why doesnt the 'set_foo' method calls the 'x' >> method if i remove the self? > > Because it now thinks that x is a local variable. This is one of the > basics of Ruby. thats the important thing! > > If you use NetBeans, the editor will alert you about these kind of > things in the colored syntax. > >> THE INTERESTING THING: 'get_foo' works with 'x' and 'self.x' > > Yes, but with different result behind the scenes. 'x' is the same as > 'x()', while 'self.x' is the same a '@x' > >> and the 2nd question: when should i use self now and when not and why is >> there this strange behavoir? > > You should use self when a left-side argument can be interpreted as a > local variable. > > > Best regards, > > Jari Williamsson -- Posted via http://www.ruby-forum.com/.