You do not call the method there, you are actually referring to the same variable that you are in the process of defining! This worked out a bit in Ruby.
What would be better if you referenced and set the instance variable instead:
@my_variable = @my_variable + 3
Or shorter:
@my_variable += 3
Or you can call the setter method as you found (and Jits point ):
self.my_variable += 3
my_variable=, attr_accessor, . , my_variable=, - , , :
def my_variable=(value)
@my_variable = value
end
BONUS
, :
my_variable = my_variable() + 3
" Ruby", , , .