If I have a class like this:
class Person
def initialize(options={})
self.name = options[:name]
end
def name=(name)
@name = name
end
end
... then the 'name=' method gets called and I get what I expect. But if I alter the example slightly to drop the 'self' from the call to 'name=' then the method is never called:
class Person
def initialize(options={})
name = options[:name]
end
def name=(name)
@name = name
end
end
Why is this? Why must 'self' be there? I was under the impression that the implicit 'self' would be set as expected in the 'initialize' constructor and therefor would behave as the first example.