Default value in hash

How do I add a default value in this hash / helper?

def doctype
{“application/msword” => “doc”, “text/rtf” => “rtf”, “text/plain” =>
“text”, “application/pdf” => “pdf”, “text/html” => “html”,
“application/vnd.ms-excel” => “excel”, “text/xml” => “xml”,
“application/mspowerpoint” => “ppt”, “image/jpeg” => “jpg”, ,
“image/gif” => “gif”, “image/png” => “png” }
end

def doctype
h = Hash.new {“some_default_value”}
h.merge({“application/msword” => “doc”, “text/rtf” => “rtf”,
“text/plain” => “text”, “application/pdf” => “pdf”,
“text/html” => “html”, “application/vnd.ms-excel” =>
“excel”, “text/xml” => “xml”, “application/mspowerpoint” =>
“ppt”, “image/jpeg” => “jpg”, “image/gif” => “gif”,
“image/png” => “png” })
end

On Aug 18, 6:42 am, Pål Bergström [email protected]

Bosco So wrote:

def doctype
h = Hash.new {“some_default_value”}
h.merge({“application/msword” => “doc”, “text/rtf” => “rtf”,
“text/plain” => “text”, “application/pdf” => “pdf”,
“text/html” => “html”, “application/vnd.ms-excel” =>
“excel”, “text/xml” => “xml”, “application/mspowerpoint” =>
“ppt”, “image/jpeg” => “jpg”, “image/gif” => “gif”,
“image/png” => “png” })
end

On Aug 18, 6:42 am, P�l Bergstr�m [email protected]

Thanks :slight_smile: