-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
add delete
for key[s] in a NamedTuple
#51098
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
Conversation
See also #46453 for a more general PR - includes delete(namedtuple) and more. Looks like implementations are somewhat different, which one is "better"? |
base/namedtuple.jl
Outdated
(a = 1,) | ||
``` | ||
""" | ||
function delete(a::NamedTuple{an}, @nospecialize(key::Symbol)) where {an} |
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.
Why is there no specialize on key::Symbol
?
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.
Thank you. I am removing it.
NamedTuple{names}(a) | ||
end | ||
|
||
function delete(a::NamedTuple{an}, @nospecialize(keys::Tuple{Vararg{Symbol}})) where {an} |
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.
I know it's a pain, but there should probably be a serious conversation concerning when tuples of indices are used and how they're interpreted. We have tuples of indices for a single index on multidim arrays, but how should we refer to multiple indices on tuples and named tuples? There's a loss of information if we require it always be another subtype of AbstractArray
@@ -1,7 +1,7 @@ | |||
# This file is a part of Julia. License is MIT: https://julialang.org/license | |||
|
|||
export | |||
# Modules | |||
# Modules |
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.
Please do not change formatting unecessarily
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.
that was unintentional -- thank you for catching the mistype
the test failures do not involve namedtuples.jl |
This PR introduces experimental |
This has many accidental formatting changes. No matter; the old version of the PR is just fine and we can merge that (it needs to be re-created though). |
Replaces #27725
This PR updates delete for NamedTuples. See that (closed) PR for much discussion. This revision supports deleting one or more keys from a NamedTuple.