From: Jamis Buck Date: 2004-11-03T06:35:59+09:00 Subject: Converting hash keys to symbols Golf question... Is there an elegant way of converting all of the keys of a hash to a symbol? The solution can assume that the existing keys are either strings or symbols. Also, if a key is a string, it may contain a dash character which must be converted to an underscore. Something like this, only more elegant, would be nice: a = some_hash_of_strings_and_symbols new_a = Hash[*a.collect { |k,v| k = k.gsub(/-/,"_").intern if k.is_a?(String) [k,v] }.flatten] Any takers? - Jamis -- Jamis Buck jgb3@email.byu.edu http://www.jamisbuck.org/jamis