Uberunix
08/27/2025, 2:24 AMYoussef Shoaib [MOD]
08/27/2025, 2:27 AMvar bar: Int
let {
bar = 5
}
// vs
let {
bar -> 5
}
matters.
Also, =
for single expression functions has no {}
, but lambdas always have {}
Uberunix
08/27/2025, 2:31 AMJoffrey
08/30/2025, 12:08 PM->
is not "return", it just separates the parameters from a lambda's body (which could contain many statements before the returned expression). In function declarations (both fun
and get
), there are parentheses for parameters, so you don't need an extra separator.
The =
sign, on the other hand, always expects a single expression on the right-hand side - you can't have statements there. So it's about whether the body has `return`s or a single expression. Lambdas are neither of those (not necessarily a single expression, and no returns), so it makes sense to me that the syntax is different