Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Hash.new(initial_capacity, &block) doc to use relevant example #14429

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
58 checks passed
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