Skip Navigation

Swift if and switch can now be expressions

www.avanderlee.com If and switch expressions in Swift

By using if and switch statements as expressions, you can omit the return keyword and reduce the lines of code while maintaining readability.

If and switch expressions in Swift

This is one feature that I missed from some other languages like Kotlin. It isn’t super useful for ifs but a switch with a lot of cases? Bring it on.

0
0 comments