self.attribute
calls the method attribute
.
self.attribute = value
calls the method attribute=
with the argument value
.
@attribute
and @attribute = value
get/set the value of the instance variable @attribute
.
So basically they're two entirely different things.
However if you call attr_accessor :attribute
it defines the method attribute
to return @attribute
and the method attribute=(value)
to set @attribute = value
. So in that case, there is no difference.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…