"Andre Nathan" <andre / digirati.com.br> schrieb im Newsbeitrag
news:1072439266.2265.4.camel / drake.mz.digirati.com.br...
> On Fri, 2003-12-26 at 09:06, Robert Klemme wrote:
> >   def method_missing(sym,*args)
> >     s = sym.to_s.freeze
>
> Is there a need to freeze s here?

unfrozen Strings are dup'ed when put into a hash.  That's why I put the
freeze there.  But the freeze should be done later, when it's clear whether
it's a setter or a getter.

> If I don't freeze it, I can do this:
>
> >     if s[-1] == ?=
> >       # setter
>
>         s.sub!(/=$/, '')
>
> >       @values[s] = args.size == 1 ? args[0] : args
> >     else
>
> This, way, if the property file looks like
>
> foo.name = 'Foo'
>
> I can access the value with
>
> conf = Config.load "conf.rc"
> puts conf.values['foo'].values['id']
>
> as opposed to
>
> puts conf.values['foo'].values['id=']

No.  The idea of the whole thing is to be able to do

puts conf.foo.name

Cheers

    robert