On Sat, Jun 27, 2009 at 10:42 AM, Fabian
Streitel<karottenreibe / googlemail.com> wrote:
> See here: http://pastie.org/526403
>
> With your example you CAN reset it to nil, but you'll have to use the
> standard getters and setters

Since this is not a DSL, I wouldn't alias name= to name, I'd just
provide an attr_writer, as you've said here.

I see:

person.name = nil

being conceivably useful  (Though again, do you have a real example of
when you nil out a set value? I can't picture why I'd do that)

but something like

person.name(nil) is seriously ugly, and doesn't make much sense.

Anyway, here's a better way to solve the problem that probably
addresses your concerns:

def name(*args)
       return @name if args.empty?
      @name = args.first
end

>> name 'foo'
=> "foo"
>> name
=> "foo"

>> name nil
=> nil
>>name
=> nil

>> name [1,2,3]
=> [1, 2, 3]
>>> name
=> [1, 2, 3]