https://kotlinlang.org logo
#coroutines
Title
# coroutines
y

yschimke

11/19/2020, 10:03 AM
I just deleted a driveby PR comment that should either be a tweet into the ether or a slack question, so here 'tis. Is CancellableContinuation.resume's handling of a cancellation lambda an example where it's less readable? I love Kotlin's last param lambda logic generally. I think in this API, this callsite is an example of where it hides the intent.
Copy code
cont.resume(Unit) { unlock(owner) }
vs
Copy code
cont.resume(Unit, onCancellation = { unlock(owner) })
t

Tim Malseed

11/19/2020, 10:56 AM
This is a special case, so I don't mean to trivialise it, but I think any lambda without a parameter name hides its intent. You never really know what's going to happen to your block of code
👍 2
2 Views