File: 04_static_hash.rdoc

package info (click to toggle)
ruby-hashery 2.1.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 404 kB
  • sloc: ruby: 2,997; makefile: 7
file content (20 lines) | stat: -rw-r--r-- 385 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
= StaticHash

A StaticHash is simply a Hash that can only be assigned
once per key. Once assigned a subsequent attempt to assign
a value to the same key will raise an ArgumentError.

  h = StaticHash.new

  h["x"] = 1

  expect ArgumentError do
    h["x"] = 2
  end

The same error will be raised when using #update or #merge!.

  expect ArgumentError do
    h.update( "x"=>3 )
  end