class Mail::Header

def []=(name, value)

h['X-Mail-SPAM'] # => nil
h['X-Mail-SPAM'] = nil
h['X-Mail-SPAM'] # => ['15', '20', '10000']
h['X-Mail-SPAM'] = '10000'
h['To'] #=> 'bob@you.com'
h['To'] = 'bob@you.com'
h.fields = ['To: mikel@me.com', 'X-Mail-SPAM: 15', 'X-Mail-SPAM: 20']
h = Header.new

Example:

the FIRST field matched from the header if passed nil
Sets the FIRST matching field in the header to passed value, or deletes
def []=(name, value)
  name = name.to_s
  if name.include?(Constants::COLON)
    raise ArgumentError, "Header names may not contain a colon: #{name.inspect}"
  end
  name = Utilities.dasherize(name)
  # Assign nil to delete the field
  if value.nil?
    fields.delete_field name
  else
    fields.add_field Field.new(name.to_s, value, charset)
    # Update charset if specified in Content-Type
    if name == 'content-type'
      params = self[:content_type].parameters rescue nil
      @charset = params[:charset] if params && params[:charset]
    end
  end
end