Skip to content

Commit b3b9aa0

Browse files
authored
ndims for AbstractArray{<:Any,N} (#40682)
1 parent d22c304 commit b3b9aa0

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

base/abstractarray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ julia> ndims(A)
234234
```
235235
"""
236236
ndims(::AbstractArray{T,N}) where {T,N} = N
237-
ndims(::Type{<:AbstractArray{T,N}}) where {T,N} = N
237+
ndims(::Type{<:AbstractArray{<:Any,N}}) where {N} = N
238238

239239
"""
240240
length(collection) -> Integer

test/abstractarray.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,11 @@ end
835835
@testset "ndims and friends" begin
836836
@test ndims(Diagonal(rand(1:5,5))) == 2
837837
@test ndims(Diagonal{Float64}) == 2
838+
@test ndims(Diagonal) == 2
839+
@test ndims(Vector) == 1
840+
@test ndims(Matrix) == 2
841+
@test ndims(Array{<:Any, 0}) == 0
842+
@test_throws MethodError ndims(Array)
838843
end
839844

840845
@testset "Issue #17811" begin

0 commit comments

Comments
 (0)