Hi,

class CGI
  class Param < String
    def initialize(array)
      self.replace(array[0].dup)
      @val = array.dup
    end
    def each(*arg, &block)
      @val.each(*arg, &block)
    end
    def [](x)
      @val[x]
    end
  end

  def initialize(arg)
    @params = {}
    arg.each() do |key, val|
      @params[key] = CGI::Param.new(val)
    end
  end
  def [](key)
    @params[key]
  end
end

test_arg = {"key1" => ["val1", "val2"], "key2"=>["val1", "val2"]}
cgi = CGI.new(test_arg)
p cgi["key1"]            # "val1"
p cgi["key1"] == "val1"  # true
p cgi["key1"].to_s       # "val1"
p cgi["key1"].to_a       # ["val1", "val2"]
p cgi["key1"].type       # CGI::Param
p cgi["key1"][0]         # "val1"    backward compatibility ;->
p cgi["key1"][1]         # "val2"

How about this?


-- 
Wakou Aoyama  <wakou / fsinet.or.jp>