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

Add Base.tail(::NamedTuple). #29595

Merged
merged 2 commits into from Oct 26, 2018

Conversation

4 participants
@tpapp
Copy link
Contributor

commented Oct 11, 2018

Fixes #29572.

@@ -273,6 +273,7 @@ values(nt::NamedTuple) = Tuple(nt)
haskey(nt::NamedTuple, key::Union{Integer, Symbol}) = isdefined(nt, key)
get(nt::NamedTuple, key::Union{Integer, Symbol}, default) = haskey(nt, key) ? getfield(nt, key) : default
get(f::Callable, nt::NamedTuple, key::Union{Integer, Symbol}) = haskey(nt, key) ? getfield(nt, key) : f()
tail(t::NamedTuple{names}) where names = NamedTuple{tail(names)}(tail(values(t)))

This comment has been minimized.

Copy link
@JeffBezanson

JeffBezanson Oct 11, 2018

Member

I think NamedTuple{tail(names)}(t) will work, and is a bit better since it will preserve field types.

@kshyatt

This comment has been minimized.

Copy link
Contributor

commented Oct 23, 2018

Is this mergeable?

@tpapp

This comment has been minimized.

Copy link
Contributor Author

commented Oct 26, 2018

Friendly ping: if there are changes to be made, please let me know, otherwise if there are no issues it would be nice to have this.

@KristofferC KristofferC merged commit 010495f into JuliaLang:master Oct 26, 2018

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
julia freebsd ci Build done
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.