Possible Duplicate:
What is attr_accessor in Ruby?
Here's the sample code:
class User
  attr_accessor :name, :email
  def initialize(attributes = {})
    @name = attributes[:name]
    @email = attributes[:email] 
  end 
....
end
When I do
example = User.new
it creates an empty user and I can assign its name and email by
example.name = "something"
example.email = "something" 
My question is, why this thing works? How does the computer know that example.name means the @name variable in the class? I'm assuming name and :name are different, and here in the code we have not explicitly told the computer that example.name is equivalent to :name symbol.
 
     
     
    