From 6045cff3b3ee4925beee1c8bf3cb758b14e16ef4 Mon Sep 17 00:00:00 2001 From: Colin Caine Date: Wed, 24 Jul 2019 01:52:41 +0100 Subject: [PATCH] Support vectors as indices to NamedTuple Fix #32662 --- base/namedtuple.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/base/namedtuple.jl b/base/namedtuple.jl index 67eaaa9efe941c..2377b67bf01fad 100644 --- a/base/namedtuple.jl +++ b/base/namedtuple.jl @@ -103,6 +103,8 @@ firstindex(t::NamedTuple) = 1 lastindex(t::NamedTuple) = nfields(t) getindex(t::NamedTuple, i::Int) = getfield(t, i) getindex(t::NamedTuple, i::Symbol) = getfield(t, i) +getindex(t::NamedTuple, v::AbstractVector{Symbol}) = [t[i] for i in v] +getindex(t::NamedTuple, i) = values(t)[i] indexed_iterate(t::NamedTuple, i::Int, state=1) = (getfield(t, i), i+1) isempty(::NamedTuple{()}) = true isempty(::NamedTuple) = false