# File lib/addressable/uri.rb, line 1432
    def query_values(return_type=Hash)
      empty_accumulator = Array == return_type ? [] : {}
      if return_type != Hash && return_type != Array
        raise ArgumentError, "Invalid return type. Must be Hash or Array."
      end
      return nil if self.query == nil
      split_query = (self.query.split("&").map do |pair|
        pair.split("=", 2) if pair && !pair.empty?
      end).compact
      return split_query.inject(empty_accumulator.dup) do |accu, pair|
        # I'd rather use key/value identifiers instead of array lookups,
        # but in this case I really want to maintain the exact pair structure,
        # so it's best to make all changes in-place.
        pair[0] = URI.unencode_component(pair[0])
        # This looks weird, but it's correct. Handles query values like:
        # ?data=1&flag&color=blue
        # In this case, `flag` would evaluate to `true`, which is what you
        # want. Its absence implies that `flag` resolves to `false`.
        # value = true if value.nil?
        if pair[1].respond_to?(:to_str)
          # I loathe the fact that I have to do this. Stupid HTML 4.01.
          # Treating '+' as a space was just an unbelievably bad idea.
          # There was nothing wrong with '%20'!
          # If it ain't broke, don't fix it!
          pair[1] = URI.unencode_component(pair[1].to_str.gsub(/\+/, " "))
        end
        if return_type == Hash
          accu[pair[0]] = pair[1]
        else
          accu << pair
        end
        accu
      end
    end