3 ms·
Ditto. These days those are the only cases where I use "let" in JS. The thing I miss most from Kotlin is the ability to return values from blocks, e.g. val res
by keeda 1y ago
Ditto. These days those are the only cases where I use "let" in JS. The thing I miss most from Kotlin is the ability to return values from blocks, e.g.
val result = if (condition) {
val x = foo()
y = bar(x)
y + k // return of last expression is return value of block
} else {
baz()
}
Or:
val q = try {
a / b
} catch (e: ArithmeticException) {
println("Division by zero!")
0 // Returns 0 if an exception occurs
}
Edit: ugh, can't get the formatting to work /facepalm.