@@ -4,28 +4,32 @@ class Hash
44 # Hash.new(capacity: 0) {|self, key| ... } -> new_hash
55 #
66 # Returns a new empty \Hash object.
7+ #
78 # Initializes the values of Hash#default and Hash#default_proc,
8- # which determine the value to be returned by method Hash#[] when the entry does not exist.
9+ # which determine the behavior when a given key is not found;
10+ # see {Key Not Found?}[rdoc-ref:Hash@Key+Not+Found-3F].
911 #
1012 # By default, a hash has +nil+ values for both +default+ and +default_proc+:
1113 #
1214 # h = Hash.new # => {}
1315 # h.default # => nil
1416 # h.default_proc # => nil
1517 #
16- # If the +default_value+ argument is provided, it sets the +default+ value for the hash:
18+ # With argument +default_value+ given, sets the +default+ value for the hash:
1719 #
1820 # h = Hash.new(false) # => {}
1921 # h.default # => false
2022 # h.default_proc # => nil
2123 #
22- # If a block is given, it sets the +default_proc+ value:
24+ # With a block given, sets the +default_proc+ value:
2325 #
2426 # h = Hash.new {|hash, key| "Hash #{hash}: Default value for #{key}" }
2527 # h.default # => nil
2628 # h.default_proc # => #<Proc:0x00000289b6fa7048 (irb):185>
2729 # h[:nosuch] # => "Hash {}: Default value for nosuch"
2830 #
31+ # Raises ArgumentError if both +default_value+ and a block are given.
32+ #
2933 # If optional keyword argument +capacity+ is given with a positive integer value +n+,
3034 # initializes the hash with enough capacity to accommodate +n+ entries without resizing.
3135 #
0 commit comments