To some extent: the underscore methods represent 'magic behaviour' i.e. this gets called implicitly by something else, you never call this directly. i.e you write 4+2 to add things not 4.add(2)
'I love that I can define + for any object in Ruby and that doing so gives me += for free.' fwiw: this works in python too >>> class Foo(object): ... def __add__(self, x): ... print "%s+%s"%(self,x) ...…
the thing is, self being explicit makes it more consistent unlike 'self' in other languages as a keyword, 'self' is just a variable with the same scoping. i.e self always refers to the most inner scope in other…
To some extent: the underscore methods represent 'magic behaviour' i.e. this gets called implicitly by something else, you never call this directly. i.e you write 4+2 to add things not 4.add(2)
'I love that I can define + for any object in Ruby and that doing so gives me += for free.' fwiw: this works in python too >>> class Foo(object): ... def __add__(self, x): ... print "%s+%s"%(self,x) ...…
the thing is, self being explicit makes it more consistent unlike 'self' in other languages as a keyword, 'self' is just a variable with the same scoping. i.e self always refers to the most inner scope in other…