Unitful and Plots, vector return types

Oh, :: vs. <: always bites me:

[1, 2]u"K" isa Vector{<:Unitful.Temperature} # true
[1, 2]u"K" isa Vector{Unitful.Temperature} # false

So I think you want:

function calctempv(v)::Vector{<:Unitful.Temperature}
	[u"270.0K" + p*u"1K/bar" for p in v]
end

or better yet, just don’t specify the return type

2 Likes