S
Shea Martin
I have been using Ruby for a while, and thought I had a pretty good
grasp of the language, but...
In an instance method, what is difference between self.my_member and
@my_member? I though 'self' was like 'this' in C++ or Java, but it
appears this is not the case. In my class, it seems possible to have
different values for the two variation.
~S
ps - this was actually seen in my Rails app, in the model. The member
variable was one inherited from AR. I was setting it's value like this:
@my_member = "sdfsdf", but the my_member column was not reflecting the
change, until I used self.my_member = "asdf". This was in an instance
method, not class method.
grasp of the language, but...
In an instance method, what is difference between self.my_member and
@my_member? I though 'self' was like 'this' in C++ or Java, but it
appears this is not the case. In my class, it seems possible to have
different values for the two variation.
~S
ps - this was actually seen in my Rails app, in the model. The member
variable was one inherited from AR. I was setting it's value like this:
@my_member = "sdfsdf", but the my_member column was not reflecting the
change, until I used self.my_member = "asdf". This was in an instance
method, not class method.