ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> ruby-rails
ruby-rails
[Rails] Re: self. vs. @
by Eric Anderson other posts by this author
Aug 13 2007 12:25PM messages near this date
[Rails] self. vs. @ | [Rails] Re: self. vs. @
Joshua Kolden wrote:
 >  how that can happen.  I also don't understand any reason for this
 >  function to call self.salt, instead of @salt.  Any clues would be much
 >  appreciated.

I don't know much about the book example you refer to but you seem to 
have some confusion between "self.salt = foo" and "@salt = foo"

When you do "@salt = foo" it is simply making the instance variable 
"salt" point to whatever "foo" is pointing at. If you do "self.salt = 
foo" then you are calling the method "salt=" with the argument "foo". 
The method "salt=" could do anything. One might think it is typically 
defined as:

def salt=(val)
   @salt = val
end

but it could be defined as

def salt=(val)
   @salt = rand
end

Sounds like you need to see how "salt=" is defined. Until then you won't 
know why it is not working.

Eric


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Ta
lk" group.
To post to this group, send email to rubyonrails-talk@[...].com
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@[...].com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Thread:
Joshua Kolden
Eric Anderson
Joshua Kolden
Eric Anderson
Vishnu Gopal
Joshua Kolden
Vishnu Gopal
Joshua Kolden

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved