hi i am very much a beginner.
i think i understand how the attr_accessor works (below). and the "setter" is the name=(name)
method. and i know that that method is equivalent to the assignment: name = "john"
. because "=" is a method that accepts an argument and assigns that argument to whatever object calls it. (though i don't understand how "name" could be considered an object as it is being assigned to an object)
so my question is: how can you assign a variable calling a method as a method name? It feels like I'm missing something..
class Person
def name
@name
end
def name=(name)
@name = name
end
end