Swift Findings: 001

Today I found two cool/interesting/surprising things about Swift.

First, a closure can be used as a conditional expression in a control flow statement and can also be executed at the same time:

We would probably not want to do this because the caller could pass in any closure, but its just cool to know that we can do this if we wanted to.


Second, I learned about two interesting pattern matching styles in switch statements:

Not sure when why if one should do this but its cool to know we can! Check out this related Twitter thread: https://twitter.com/garricn/status/916444820951916545