I want to dispatch based on whether the type has fields or not. I have now
hasfieldnames(::Type{T}) where T = fieldnames(T) >= 1
fn(::Type{T}) where T = begin
if hasfieldnames(T)
_fn_has_field_name(T)
else
_fn_has_no_field_name(T)
end
end
Is this the best way? I think the if-else
is redundant and potentially bad for performance and can be gotten rid of if I knew how to make fn
dispatch on whether T
has field names or not.