I came across this line in production
let animated = presentedViewController == nil && route.animateTransition == false ? false : true
It’s more confusing than you’d expect. My initial thought is that it was equivalent to
let animated3 = (presentedViewController == nil && route.animateTransition) == false ? false : true
but that ending
) is out of place. Everything before a ternary operator will be executed before the remaining cases. So it’s actually
let animated4 = (presentedViewController == nil && route.animateTransition == false) ? false : true
Still not very readable. The next clue to break this down is that
? false : true is very long-hand for
!. So that statement is equivalent to
let animated5 = !(presentedViewController == nil && route.animateTransition == false)
It’s really hard to keep on breaking down this statement until you take a step back and try to guess at what the author was trying to achieve. It seems like you would want something to be animated if
true or if the presented controller exists. This could be animating a dismissal of a controlller or something like that.
Eventually, you can simplify it down to
let animated6 = presentedViewController != nil || route.animateTransition
It’s ~1000x more readable and much more clearly expresses the author’s intent. Here is the Gist with some of the intermediate steps taken out.