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

Allow for recursive merge of NamedTuples #29215

Closed
stakaz opened this issue Sep 16, 2018 · 3 comments
Closed

Allow for recursive merge of NamedTuples #29215

stakaz opened this issue Sep 16, 2018 · 3 comments
Labels
feature Indicates new feature / enhancement requests

Comments

@stakaz
Copy link

stakaz commented Sep 16, 2018

Hello, it would be great, when something like this:

Base.merge(front::NamedTuple, tail::NamedTuple...) = merge(merge(front, tail[1]), tail[2:end]...)

would be available in Base.

It is a very common thing to merge multiple tuples together and would be really a sweet sugar. like this:

julia> A = (a = 1, b = 1);
julia> B = (a = 2, c = 2);
julia> C = (b = 3, d = 2);
julia> merge(A,B,C)
(a = 2, b = 3, c = 2, d = 2)

Are there any reasons this is not in Base?

Thanks

@JeffBezanson
Copy link
Member

Yes, this could be added.

@StefanKarpinski StefanKarpinski added the feature Indicates new feature / enhancement requests label Sep 16, 2018
jpsamaroo added a commit to jpsamaroo/julia that referenced this issue Sep 18, 2018
@jpsamaroo
Copy link
Member

I created a small PR, using @stakaz 's function definition almost verbatim. It seems to pass namedtuple tests, but I hope I didn't miss something...

@fredrikekre
Copy link
Member

#29259

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Indicates new feature / enhancement requests
Projects
None yet
Development

No branches or pull requests

5 participants