On Thu, Jun 25, 2009 at 11:29 AM, Ryan Davis<ryand-ruby / zenspider.com> wrote:
> On Jun 25, 2009, at 11:05 , Marc Heiler wrote:
>
>> This does not seem to work. My question is, why was = used, but so many
>> people in their ruby code also allow the last version? It usually has
>> this form:
>>
>> object.set_bla 'foo'
>
> no, we don't. I'd argue strongly against "so many". It is highly
> non-idiomatic.

Generally you'll see the set_bla behavior in a few cases:

1. Code from folks who, as Ryan said, aren't writing idiomatic Ruby.
People who come over from languages like Java or C++ are used to more
formal accessor/mutator method pairs.

2. Code that's exposing a declarative DSL, e.g.

    person do
      name "John Doe"
      phone "206-867-5309"
    end

Personally, I prefer to stick with simple foo = bar or thing.foo = bar
for assignment, even in DSLs.


~ j.