-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Description
I had hoped that indexing a named tuple (#22194) with a Symbol would be a type-inferrable operation. I'm guessing that a tfunc or whatever, like for Tuple, may be needed here.
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: https://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.7.0-DEV.2400 (2017-11-02 03:12 UTC)
_/ |\__'_|_|_|\__'_| | ajf/empty/5fa163f (fork: 1 commits, 0 days)
|__/ | x86_64-linux-gnu
julia> nt = (a=1, b=2.0)
(a = 1, b = 2.0)
julia> f(x) = x[:a]
f (generic function with 1 method)
julia> @code_warntype f(nt)
Variables:
x::NamedTuple{(:a, :b),Tuple{Int64,Float64}}
Body:
begin
return (Base.getfield)(x::NamedTuple{(:a, :b),Tuple{Int64,Float64}}, :a)::Union{Float64, Int64}
end::Union{Float64, Int64}
Metadata
Metadata
Assignees
Labels
No labels