JuliaData / NamedTuples.jl

[DEPRECATED] NamedTuples.jl
Other
30 stars 17 forks source link

Create a NamedTuple from a tuple of symbols and a tuple of values #53

Open femtotrader opened 6 years ago

femtotrader commented 6 years ago

Hello,

A NamedTuple can be created using

julia> @NT(x,y)(1,2)
(x = 1, y = 2)

but I wonder if there is a way to create a NamedTuple using a tuple of symbols and a tuple of values. Something like:

julia> @NT(:x, :y)(1,2)

Any idea?

femtotrader commented 6 years ago

It seems to be possible using:

julia> using NamedTuples: make_tuple

julia> make_tuple([:x,:y])(1,2)
(x = 1, y = 2)

Is there a better method to do this?

Maybe we should improve doc?

omus commented 6 years ago

In #52 you can do: NamedTuple{(:x, :y)}(1, 2). Does that seem better to you?

femtotrader commented 6 years ago

This syntax is much nicer. We can close this issue when #52 will be merged