4 ms·
The syntax is a lot more intuitive in Julia: julia> point = (x=1, y=2) (x = 1, y = 2) julia> point.x 1 julia> point.y 2 julia> dump(point) NamedTuple{(:
by msravi 5y ago
The syntax is a lot more intuitive in Julia:
julia> point = (x=1, y=2)
(x = 1, y = 2)
julia> point.x
1
julia> point.y
2
julia> dump(point)
NamedTuple{(:x, :y), Tuple{Int64, Int64}}
x: Int64 1
y: Int64 2
- bobbylarrybobby 5y agoAnd to create one as an anonymous type, you can use the `@NamedTuple` macro: julia> @NamedTuple{x::Int, y::String} NamedTuple{(:x, :y), Tuple{Int64, String}}
- mdcfrancis 5y agothey are also, type stable, strongly typed and have the same overhead as a struct. So an array of NamedTuples takes the minimal space and allocation.
- rdtsc 5y agoI guess one difference is that when you inspect it, it doesn't indicate that it is a `point`, just that it's named tuple of two variables, so it's not exactly equivalent.