News for hackers. Stuff that matters.
Re:Reasons that PHP is better than Ruby by regularfry on Monday February 21, 2011 @05:50PM (#2247644)
In Ruby, you can't[0] access an instance variable without an accessor; they're private by default, with all that implies. Also, when you use attr_accessor, all it does is literally[1] create a getter and a setter method. Adding logic to them later is a simple matter of replacing the attr_accessor shortcut with a method with the right name. None of the client code has to change, and that's the important part.

[0] Not quite; see Object#instance_variable_get. But that's cheating, ugly, and generally frowned upon.

[1] Not quite, but the difference is an implementation detail.

There are no comments on this comment yet.