Skip to content

Conversation

lachlan
Copy link
Contributor

@lachlan lachlan commented Apr 4, 2024

The Hash.new(initial_capacity = nil, &block : Hash(K, V), K -> V) comment's first code example calls a different constructor rather than the constructor being documented:

inventory = Hash(String, Int32).new(0) # => actually calls Hash.new(default_value : V, initial_capacity = nil)
inventory["socks"] = 3
inventory["pickles"] # => 0

Fixed to provide an example of how to use the Hash.new(initial_capacity = nil, &block : Hash(K, V), K -> V) constructor instead.

@straight-shoota straight-shoota merged commit dbf7aef into crystal-lang:master Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants