Swift

One-Line If-Else in Swift

Did you know that you can replace this simple if-else statement in Swift: with this neat one-liner expression? This is possible thanks to what is called a ternary conditional operator in Swift. The Full Syntax For your convenience, here is the structure of a ternary operator: Where: How to Use It? A ternary conditional operator offers a shorthand that

One-Line If-Else in Swift Read More »

Scroll to Top