-
-
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
fix ImmutableDict(pairs...) constructor #36143
Conversation
It could only handle a couple of pairs, e.g. ImmutableDict(1=>1, 2=>2, 3=>3) would throw. The fix is implemented by adding the `ImmutableDict(t::ImmutableDict, pairs...)` constructor, which generalizes `ImmutableDict(t::ImmutableDict, pair)` (with some similarity to how `push!` accepts multiple items to be pushed).
It could only handle a couple of pairs, e.g. ImmutableDict(1=>1, 2=>2, 3=>3) would throw. The fix is implemented by adding the `ImmutableDict(t::ImmutableDict, pairs...)` constructor, which generalizes `ImmutableDict(t::ImmutableDict, pair)` (with some similarity to how `push!` accepts multiple items to be pushed). (cherry picked from commit 162cde1)
Is there a reason behind the absence (I guess, tell me if I missed it) of an ImmutableDict constructor from a Dict (AbstractDict)? It is pretty near the multiple pairs constructor but could be useful for automatic conversion with function return type, I think. OrderedDict from DataStructures and Dict from Base implement this constructor too. Something like |
I don't think there is any reason, besides that this I could have used a |
That explains why it needs to be imported manually… Honestly, I bumped into it from here then there because I was searching a good pattern to avoid a lot of tramp data across many functions because of a Dict variable (almost only constants in a hierarchical structure, like database parameters, regexes and paths), so naturally I found the global configuration variable… |
It could only handle a couple of pairs, e.g. ImmutableDict(1=>1, 2=>2, 3=>3) would throw. The fix is implemented by adding the `ImmutableDict(t::ImmutableDict, pairs...)` constructor, which generalizes `ImmutableDict(t::ImmutableDict, pair)` (with some similarity to how `push!` accepts multiple items to be pushed).
It could only handle a couple of pairs, e.g.
ImmutableDict(1=>1, 2=>2, 3=>3)
would throw.The fix is implemented by adding the
ImmutableDict(t::ImmutableDict, pairs...)
constructor,which generalizes
ImmutableDict(t::ImmutableDict, pair)
(with some similarity to how
push!
accepts multiple itemsto be pushed).