From: "David A. Black" Date: 2009-06-26T04:59:31+09:00 Subject: Re: Attr Methods and object setters Hi -- On Fri, 26 Jun 2009, Marc Heiler wrote: >> no, we don't. I'd argue strongly against "so many". It is highly non- >> idiomatic. > > Ruby/GTK > > I guess I can hunt around which ruby-projects are using set_* > specifically just to document whether it is common or not, but I can > already see that my question is not addressed regarding the attr* > decisions. Do you mean something like attr_accessor_using_set_and_get_methods :name I'm not sure how to analyze why this isn't in the language, since I can't picture it being there. I guess it's partly because the language supports the idea of attributes as pseudo-L-values; in other words, when you do this: person.name = "David" you're doing something that looks like an assignment, but is actually a method call. Lots of things in Ruby look like something but are actually method calls (like array[1] = 100, or the when clauses in a case statement). Also, set_name(arg) is really just another method. There's nothing special about it. Someone might decide to avoid writing accessor methods and write get/set ones instead (though I discourage it), but they might decide to write lots of different methods, and the language can't provide shortcuts for all of them. David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Now available: The Well-Grounded Rubyist (http://manning.com/black2) "Ruby 1.9: What You Need To Know" Envycasts with David A. Black http://www.envycasts.com