Skip to content
trans edited this page Oct 12, 2010 · 2 revisions

Stash is just like Hash, except that all keys are converted to Strings.

require 'hashery/stash'

h = Stash.new
h[:a] = 1
h[:b] = 2
h  #=> {'a'=>1, 'b'=>2}

This is true regardless of the type of key used --all will receive the #to_s message upon assignment.

h = Stash.new
h[1]   = 1
h[nil] = 2
h  #=> {'1'=>1, ''=>2}    

Note On Separate Gem

Stash used to be a standalone library. In fact, you can still install stash as a separate gem. However you will get a aging discontinued version of the class. All new development is only available via hashery.

Clone this wiki locally