The current release 0.0.1 hasn't been used in many places. So if you find defects, send them to me. I'll get it fixed asap. So far I've create a bunch of unit tests to verify TofuHash behavior. These unit tests include modified versions of Ruby's Hash unit tests, sourcecode examples from the ri documentation of Hash, plus some of my own tests.
So far I've avoided monkey patching Hash. So there is a known issue where Hash doesn't always know how to handle TofuHash. For example, you can't compare Hash to TofuHash(myHash == myTofuHash), but the reverse is possible (myTofuHash == myHash).
The easiest way to create and populate a TofuHash is to use Hash's [ ] syntax as shown here:
require 'tofuhash'
h = TofuHash[ :aSymbol => "symbol", "MixedCaseString" => "string", 11 => "number" ]
puts h["asymbol"] #=> "symbol"
puts h[:mixedCaseString] #=> "string"
puts h[11] #=> "number"
No comments:
Post a Comment