Today I learned a closure trick in Swift. Usually when expression is assigned to a variable on left, it is evaluated instantly.
For example,
let value = complexCalculation()
func complexCalculation() -> String {
return "Something useful"
}
In this example, when value is assigned a result of complexCalculation() method, it is called immediately.