Beginning iOS Animations · Animating Constraint Multipliers | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/9051-beginning-ios-animations/lessons/6

Hi,

What purpose does the return serve in the forEach() closure of the titleLabel.superView.constraints if it doesn’t break out of the loop once reached?

1 Like

Hi! Thanks for asking. I can see why that would be confusing.

I expect those two if statement conditions to be mutually exclusive. So the return is there because I wouldn’t want to bother to check the second condition if the first were true, but I would want to continue the loop.

It probably would have been much more clear to use an else if for that second condition, or even use a for loop instead of forEach.