Skip to content

Conversation

@travissarles
Copy link
Contributor

No description provided.

@travissarles travissarles mentioned this pull request Mar 17, 2017
33 tasks
Copy link

@maasg maasg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the standalone format, not comparing every time to Java.
I miss a caveats section, like combining default values with overrides.

There's really only two constructors here; one that takes another map, and one that takes a capacity and load factor. The third and fourth constructors are there to allow users of <code>HashMap</code> to create instances with the probably-good-for-most-cases defaults of both load factor and capacity.

More problematic is that the values used for defaults are in both the Javadoc *and* the code. Keeping this up to date is easily forgotten. A typical pattern around this would be to add public constants whose values will show up in the Javadoc:
The parameter `level` has a default value so it is optional. Where you might do overloaded methods in Java, you can use methods with optional parameters to achieve the same effect. However, ff the caller omits an argument, any following arguments must be named.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, if the caller...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.

@travissarles
Copy link
Contributor Author

I do combine default values with overrides in the second code example I think. Is that not what you're talking about?

@travissarles travissarles self-assigned this Mar 21, 2017
@travissarles travissarles merged commit a993230 into scala:master May 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants