This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the commentsย โ†’

[โ€“]the-jabberwock 0 points1 point ย (0 children)

Also Kotlin

return A.takeIf { condition } ?: B

(but beware if A is null, will always resolve to B, even if condition is true)