From: Joel Pearson Date: 2013-05-07T07:32:22+09:00 Subject: Re: NoMethodError split for array using optional parameter I'm not entirely sure what you're doing there, but I've tried to tidy up the logic a bit for you: def cookies( arg = nil ) @cookies_hash ||= {} return cookies_to_s if arg.nil? arg = arg.split(';') unless arg.is_a?( Array ) arg.each { |e| res = e.scan(/([^=]*)=([^=]*)/).flatten res[0].downcase! next if res.size != 2 || %w(expires max-age domain path).include?(res[0]) @cookies_hash[ res[0] ] = res[ 1 ] } cookies_to_s end def cookies_to_s @cookies_hash.map{|k, v| "#{k}=#{v}"}.join("; ") end -- Posted via http://www.ruby-forum.com/.