Comment 2 for bug 1366009

Revision history for this message
Dmitry Ilyin (idv1985) wrote :

Actually it's a very funny Ruby problem

In ruby classes you can define setters and getters for a attributes:

def attr
  puts 'get attr'
  @attr
end

def attr=(value)
  puts 'set attr'
  @attr = value
end

then you can set and get this attr

put myclass.attr
myclass.attr = 1

Ok, then setter method is named 'attr=' what if i want to call if from within the class

attr = 1 -> it will not work. set local variable attr to 1
attr= 1 -> same
attr=(1) -> same

in this case we have to use self like in Python

self.attr = 1 -> ok using getter magic
self.attr= 1 -> ok calling directly
self.attr=(1) -> same