From: Luke Ivers Date: 2007-02-09T04:42:17+09:00 Subject: Help optimizing I'm going to cross-post this from the Rails group, because some of the people here are Ruby ninjas and don't read that forum, and I'd like help getting this function optimized... its results are useful in a Rails perspective, but it's functionality has nothing to do with Rails at all. class Hash def to_params(parent = '') ret = '' self.keys.each do |key| if self[key].is_a? Hash if parent == '' ret += self[key].to_uri(key.to_s) else ret += self[key].to_uri(parent + "[#{key.to_s}]") end else if parent == '' ret += "#{key}=#{self[key]}&" else ret += "#{parent}[#{key}]=#{self[key]}&" end end end return ret.chomp('&') end end Anybody got any optimizations(either quicker speed, or less text and comparable speed) for that one? Thanks. -- Posted via http://www.ruby-forum.com/.