Swift

What is the Difference between Let and Var in Swift?

In Swift, there are two types of values: Constants. These are immutable variables. Variables. These are mutable variables. To declare constants/variables in Swift: let is used to declare an immutable constant. You cannot change the value of it later. var is used to create a mutable variable that you can change later. For example, to …

What is the Difference between Let and Var in Swift? Read More »

Swift One-Line If-Else

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. For your convenience, here is the structure of a ternary operator: Where: condition is an expression that evaluates to true or false. true_expression is the piece of …

Swift One-Line If-Else Read More »