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 an example of programatically creating a named tuple #32330

Merged
merged 4 commits into from
Jul 2, 2019

Conversation

KristofferC
Copy link
Sponsor Member

This seems to be relatively unknown.

@KristofferC KristofferC added the docs This change adds or pertains to documentation label Jun 15, 2019
base/namedtuple.jl Outdated Show resolved Hide resolved
@pshashk
Copy link

pshashk commented Jun 17, 2019

Version without comma works as well (;zip(keys, values)...)

@KristofferC
Copy link
Sponsor Member Author

Thanks for comments, updated accordingly.

@StefanKarpinski StefanKarpinski merged commit 458b449 into master Jul 2, 2019
@StefanKarpinski StefanKarpinski deleted the KristofferC-patch-8 branch July 2, 2019 21:55
@o314
Copy link
Contributor

o314 commented Oct 11, 2019

I was just going to propose a patch for this. It's not on v1.2
But you've done it for v1.3 (or v1.4)
Thanks.


Forgetting this leads to loss of time every time you miss it. Quite often in fact!
It is not so easy to find in docs. An extraline in docstring could do the job.

And because NamedTuple{keys(itr)}(values(itr)) is not a good friend gift.

One could patches

!!! NamedTuple `nt` can be reconstruct from iterator `itr` yielded by `pairs(nt)`
with the syntax `(;itr...)`

...

julia> itr = pairs((a = 1, b = 2)); (;itr...)
(a = 1, b = 2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants