Skip to content

Allow empty componentarrays #115

@JTaets

Description

@JTaets
ComponentArray(a=Int[]) #fails
ComponentArray(a=Int[],b=[4,5]) #works

In my code, a can or cannot contain values. But in both cases, I would like to be able to use the same code by allowing empty componentarrays.

This line in the code prevents empty componentarrays. (reduce isn't allowed for empty arrays).

This is easily fixed by changing that line to

if length(data) == 1
    data = [data[1]]
elseif length(data) > 1
    data = reduce(vcat, data)
end

Note: type info for the array a is needed, or another error is thrown.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions