| In: |
basiclibrary.rb
|
| Parent: | Hash |
A Hash object which raises an error if any previously-defined key attempts to be set again.
foo = WriteOnceHash.new
foo['name'] = 'Gavin' => 'Gavin'
foo['age'] = 31 => 31
foo['name'] = 'Bob'
=> Error: WriteOnceHash has a value for key 'name' in object:
{"name"=>"Gavin", "age"=>31} (RuntimeError)