4 ms·
The absence of guard in Kotlin is one of those things that regularly trips me up when bouncing between it and Swift. Rather than Swift losing guard I’d prefer i
by cosmic_cheese 7mo ago
The absence of guard in Kotlin is one of those things that regularly trips me up when bouncing between it and Swift. Rather than Swift losing guard I’d prefer if Kotlin gained it.
- iamcalledrob 7mo agoI think the ?: operator ends up being a decent alternative, e.g. // Swift guard let foo = maybeFoo else { print("missing foo") return false } // Kotlin val foo = maybeFoo ?: run { print("missing foo") return false } Unless there's a use case for guard I'm not thinking of
- cosmic_cheese 7mo agoIt’s a decent alternative, but to someone not familiar with the language what’s going on isn’t as clear.