On 12/1/06, Yukihiro Matsumoto <matz / ruby-lang.org> wrote:
> In message "Re: why does openstruct not respond to [] and []=?"
>     on Fri, 1 Dec 2006 21:35:42 +0900, "Martin DeMello" <martindemello / gmail.com> writes:
> |{
> |    :verbose => ["-v", "--[no-]verbose", "run verbosely"],
> |    :all => ["-A", "--all", "select all files"],
> |    #....
> |}.each {|k,v| opt.on(*v) {|i| opts.send(:"#{k}=", i) } }
> |
> |The last line would have been a lot less ugly as opts[k] = i, and as I
> |said, there seems no real reason not to allow it.
>
> Is there any reason that you have to use OpenStruct instead of plain
> hash as opts?

In the rest of the code I'd far rather use opts.option than
opts[:option] - the latter ends up looking cluttered.

martin