From: "David A. Black" Date: 2003-12-15T21:35:14+09:00 Subject: Re: Q: How to convert hashed parameters to local variables? Hi -- On Mon, 15 Dec 2003, ts wrote: > >>>>> "D" == David A Black writes: > > D> No it doesn't. Well, strictly speaking it does, since "current > D> scope" means its own block, which it then exits causing the > D> variables to go out of scope. But if by "current scope" you mean > D> the scope from which eval was called, then, as my example shows, > D> the variables are not created in that scope. > > not understood, sorry > > svg% cat b.rb > #!/usr/bin/ruby > args = { "a" => "hello" } > str = "" > args.each do |key,val| > str << "#{key}='#{val}'\n" > end > eval str > eval 'puts a' > svg% > > svg% b.rb > hello I was saying that if you do puts a instead of eval 'puts a' 'a' will not be known. This was in response to Greg's post. Mind you, I forgot about the fact that you can re-eval 'a' and get back the same 'a' -- but here the goal was to create variables at the scope surrounding the eval, not in the eval block itself. David -- David A. Black dblack@wobblini.net