-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Add doctest for IdDict with example #38881
Conversation
This came up from a Slack discussion and was based on a surprising [Python behavior](https://twitter.com/DahlitzF/status/1338384990040682498). @haampie provided the example and I thought the docstrings could help out another beginner to understand why a different data structure is justified.
base/iddict.jl
Outdated
@@ -6,7 +6,23 @@ | |||
`IdDict{K,V}()` constructs a hash table using object-id as hash and | |||
`===` as equality with keys of type `K` and values of type `V`. | |||
|
|||
See [`Dict`](@ref) for further help. | |||
See [`Dict`](@ref) for further help. In the example below, The `Dict` | |||
keys all hash to the same value as they are inserted and type-promoted, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There isn't really any type promotion going on here though, the values are all isequal
and hash the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the catch. Should be fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect 👨🏻🍳😽
This came up from a Slack discussion and was based on a surprising [Python behavior](https://twitter.com/DahlitzF/status/1338384990040682498). @haampie provided the example and I thought the docstrings could help out another beginner to understand why a different data structure is justified.
This came up from a Slack discussion and was based on a surprising Python behavior.
@haampie provided the example and I thought the docstrings could help out another beginner to understand why a different data structure is justified.