@shaz
Yes, it is assigning the value to a local variable instead of performing the assignment method. The local variable namespace has a higher priority than the instance level if there is ambiguity (you could either be creating a new instance variable or performing the assignment method). It becomes a Ruby "gotcha" because though the logical assumption would be that you
shouldn't use name your local variables the same thing as your instance methods; it doesn't mean that you
can't. For instance methods, this is generally a non-issue because a local variable does not exist at that point so the ambiguity is removed.
For example, you would not need the self modifier here because the syntax is not ambiguous:
Code:
alias shaz_assign_hp hp=def hp=(hp) shaz_assign_hp(hp)end
Even if there is already something in the namespace at the local level:
Code:
alias shaz_assign_hp hp=def hp=(hp) shaz_assign_hp = nil shaz_assign_hp(hp)end
You wouldn't need it here:
Code:
alias hp_nonsense hp def hp hp_nonsense end
However, you would definitely need it here:
Code:
alias hp_nonsense hp def hp hp_nonsense = 100 self.hp_nonsense end