In the code below, starting_node
isn't being interpreted as a setter method if I omit self
; it becomes a local variable.
class Stack
attr_accessor :starting_node
def push(node)
...
self.starting_node = node
...
end
end
Why is the explicit self
needed when it works implicitly elsewhere?
How does variable assignment work if this:
local_variable.=("some string")
is invalid, that is what is it if not a method?