| Class | Relax::SymbolicHash |
| In: |
lib/relax/symbolic_hash.rb
|
| Parent: | Hash |
SymbolicHash provides an extension of Hash, but one that only supports keys that are symbols. This has been done in an effort to prevent the case where both a string key and a symbol key are set on the same hash, and espcially for dealing with this particular case when convert the hash to a string.
hash = Relax::SymbolicHash.new hash[:one] = 1 hash['one'] = 2 puts hash[:one] # => 2
Some of the inspiration (and code) for this class comes from the HashWithIndifferentAccess that ships with Rails.