struct OrderedPair
x::Real
y::Real
function OrderedPair(x, y, ::Val{Checks}=Val(true)) where {Checks}
if Checks
x > y || error("out of order")
end
new(x, y)
end
end
This way you can avoid the checks when you are 100% sure that the values you are feeding to the constructor satisfy all the requirements. If you call OrderedPair(x, y, Val(false)), the checks are statically removed.
Thanks for the correction, Tamas_Papp: I really meant what you said and wanted to call attention to the very useful (at least to me, as a newbie) Parameters.jl package.