Skip to content

Commit 4fdfe36

Browse files
Make haskey work for LazyArray
1 parent 664eb73 commit 4fdfe36

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ComponentArrays"
22
uuid = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
33
authors = ["Jonnie Diegelman <47193959+jonniedie@users.noreply.github.com>"]
4-
version = "0.15.15"
4+
version = "0.15.16"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"

src/lazyarray.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ Base.propertynames(a::LazyArray) = propertynames(first(a))
3030

3131
Base.keys(a::LazyArray) = Base.OneTo(length(a))
3232

33+
Base.haskey(a::LazyArray, i::Integer) = i in keys(a)
34+
3335
Base.iterate(a::LazyArray) = iterate(getfield(a, :gen))
3436
Base.iterate(a::LazyArray, state...) = iterate(getfield(a, :gen), state...)
3537

test/runtests.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,9 @@ end
345345
@test propertynames(ca2) == (:a, :b, :c) # ComponentArray
346346
@test propertynames(ca2.b) == (:a, :b) # LazyArray
347347

348+
@test haskey(ca2, :a) # ComponentArray
349+
@test haskey(ca2.b, 1) # LazyArray
350+
348351
@test keys(ca2) == (:a, :b, :c)
349352
@test keys(ca2.b) == Base.OneTo(2)
350353
end

0 commit comments

Comments
 (0)