Sha256: accb43e8a697f05145ea434a87f49e4194e4d8b4bee90c356329ecd70d5fd638
Contents?: true
Size: 715 Bytes
Versions: 4
Compression:
Stored size: 715 Bytes
Contents
= PropertyHash The Property hash can be used an object in itself. h = PropertyHash.new(:a=>1, :b=>2) h[:a] #=> 1 h[:a] = 3 h[:a] #=> 3 Becuase the properties are fixed, if we try to set a key that is not present, then we will get an error. expect ArgumentError do h[:x] = 5 end The PropertyHash can also be used as a superclass. class MyPropertyHash < PropertyHash property :a, :default => 1 property :b, :default => 2 end h = MyPropertyHash.new h[:a] #=> 1 h[:a] = 3 h[:a] #=> 3 Again, if we try to set key that was not fixed, then we will get an error. expect ArgumentError do h[:x] = 5 end
Version data entries
4 entries across 3 versions & 2 rubygems