Skip to content

Commit

Permalink
Support vectors as indices to NamedTuple
Browse files Browse the repository at this point in the history
Fix #32662
  • Loading branch information
cmcaine committed Jul 24, 2019
1 parent 9daaed6 commit 6045cff
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions base/namedtuple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6045cff

Please sign in to comment.