My code:
def distance(a, b):
ta = type(a)
tb = type(b)
if (ta == Vector and tb == Line):
return ObjectRelations.point_to_line_distance(a, b)
if (ta == Line and tb == Vector):
return ObjectRelations.point_to_line_distance(b, a)
Is there a way to do both if
comparisons in one? The order of arguments given to point_to_line_distance
matters because of how my Vector
and Line
objects work. I want to check if either a
or b
is a Line
and then check whether the other one is a Vector
.
What would the best way to do this?
My way of doing it would work, but I just want to write clean code and my solution is not ideal.