On 2002.07.10, Philip Mak <pmak / animeglobe.com> wrote:
> I'm trying to make a function that is called like this:
> 
>     cgi.export(%w(name email phone))
> 
> which would have the same effect as this:
> 
>     name = cgi['name'][0]
>     email = cgi['email'][0]
>     phone = cgi['phone'][0]

class CGI
  def [](x)
    [x]
  end
  def export(args)
    args.each { |arg| self[arg][0] }
  end
end
    
cgi = CGI.new

p defined? name   # => nil
p defined? email  # => nil
p defined? phone  # => nil

name, email, phone = cgi.export %w(name email phone)

p name    # => "name"
p email   # => "email"
p phone   # => "phone"


Not exactly what you want, but maybe close enough?

-- Dossy

-- 
Dossy Shiobara                       mail: dossy / panoptic.com 
Panoptic Computer Network             web: http://www.panoptic.com/ 
  "He realized the fastest way to change is to laugh at your own
    folly -- then you can let go and quickly move on." (p. 70)