Victor 'Zverok' Shepelev
9/25/2007 10:18:00 PM
From: list-bounce@example.com [mailto:list-bounce@example.com] On Behalf Of
Emmanuel Oga
Sent: Wednesday, September 26, 2007 1:09 AM
>
>Hi! i need a solution for this, it's pretty simple but i can't get it to
>work...
>
>suppose:
>
>class Options
>
> def self.define_an_option
> # ...don't-know-how-implementation :(
> end
>
> define_an_option :option1, String
> define_an_option :option2, Array
>end
>
>Then, i want to do something like this:
>
>opt= Options.new
>opt.option1 => ""
>opt.option2 => []
>
>opt.option1 do |o|
> o= "Hello"
>end
>
>opt.option2 do |o|
> o << 10
>end
>
>options.option1 => "Hello"
>options.option2 => [10]
>
Before you do it, you should understand your API examples seems unnatural.
Why not to do
opt.option1 = "Hello"
opt.option2 << 10
?
Than, this example:
opt.option1 do |o|
o = "Hello"
end
is almost impossible to do (possible, but hard), because it should read
like: "pass reference option value into block though 'o' variable; replace
'o' with reference to 'Hello' string" - option value will left untouched.
V.