Methods and instance variables: should there be a difference?
Posted by: nico on
Oct 19th, 2009 |
Filed under: Grumpy, Programming
Could be changed to
class Foo
@bar
def bar=(val) @bar = val end
end
foo.bar = 1
and the dependant objects using the property would use the new behaviour without ever needing a change in the way bar is accessed.
In languages like C++ the parentheses are mandatory so you can have a clear difference between instance variables and methods, and between a method call and a function pointer (which should be referenced as &Foo::bar and not Foo::bar anyway).
All of this always leads to the same conclusion: closing parenthesis should not be needed!




Add A Comment