Ben explains that it is redundant to add an else statement after comparing distanceA to distanceB. I do not understand how that is the case.
This was how he showed us.
This makes more sense to me.
This is where the GetClosest(); method is used.
Ben explains that it is redundant to add an else statement after comparing distanceA to distanceB. I do not understand how that is the case.
This was how he showed us.
This makes more sense to me.
This is where the GetClosest(); method is used.
Oh I think I see it now. If the if statement returns transformA, then the method will stop executing from there. And if the if statement conditions are not met, then it will continue the method until it returns transformB. Is that correct?
Yes, that’s it. When we return
from a method, nothing further is executed in there. if distToA
is less than distToB
we will return transformA
and the rest of the code will not execute.
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.