From: "David A. Black" Date: 2003-12-15T21:17:14+09:00 Subject: Re: Q: How to convert hashed parameters to local variables? Hi -- On Mon, 15 Dec 2003, Gregory Millam wrote: > Received: Mon, 15 Dec 2003 11:38:30 +0900 > And lo David wrote: > > > > The variables you create that way will only be in scope in the > > eval block itself: > > > > eval "a = 1; puts a" # 1 > > puts a # error: a is undefined > > > > > > David > > > > Not quite; eval creates variables at current scope, But you are No it doesn't. Well, strictly speaking it does, since "current scope" means its own block, which it then exits causing the variables to go out of scope. But if by "current scope" you mean the scope from which eval was called, then, as my example shows, the variables are not created in that scope. Your example shows the same thing actually :-) $ cat ev.rb args = { "a" => "hello" } str = "" args.each do |key,val| str << "#{key}='#{val}'\n" end eval str puts a $ ruby ev.rb ev.rb:8: undefined local variable or method `a' for main:Object (NameError) David -- David A. Black dblack@wobblini.net