From: Jeffrey Schwab Date: 2006-02-05T03:43:25+09:00 Subject: Re: Extract hash into local variables? csn wrote: > Is there a Ruby function similar to PHP's extract/list? What I'd like to > do is: > > def foo(args={a=>1, b=>2, c=>3}) > args.extract > > puts a > puts b > puts c > end I'm kind of disturbed by how hard this actually seems. There does not seem to be any decent way to modify the set of local variables through introspection. Here's a weak work-around: def foo(args={:a=>1, :b=>2, :c=>3}) @args = args def method_missing(m) @args[m] end puts a puts b puts c end foo