Type of array containing units from Unitful

This doesnโ€™t work because Quantity{<:Real, Unitful.๐“, typeof(Unitful.yr)} is an abstract type, but the array you are passing has is a concrete element type (which is a subtype of the above). You need to add another <: like this:

array_unit::Array{<:Quantity{<:Real, Unitful.๐“, typeof(Unitful.yr)}, 1}

Yes, there is the Unitful.Time type alias, which matches all quantities with time units:

array_unit::Array{<:Unitful.Time{<:Real}, 1}
1 Like