
Kotlin
文章平均质量分 84
Th.one
卖哈哈隆
展开
-
Kotlin--suspendCancellableCoroutine和suspendCoroutine的区别及使用
站在巨人的肩膀上:https://medium.com/swlh/kotlin-coroutines-in-android-suspending-functions-8a2f980811f8 前言: ① 使用 suspendCancellableCoroutine 和 suspendCoroutine 可以将回调函数转换为协程 ② SuspendCancellableCoroutine 返回一个 CancellableContinuation, 它可以用 resume、resumeWithException翻译 2021-02-07 10:48:45 · 9336 阅读 · 0 评论 -
Kotlin--Sequence的使用及与Iterable的区别
序列(Sequence) VS 集合(Iterable) 举个例子:给定一个字符串,过滤长于三个字符的单词,并打印前四个单词的长度 Iterable写法: fun main() { val words = "The quick brown fox jumps over the lazy dog".split(" ") val lengthsList = words.filter { println("filter: $it"); it.length > 3 }原创 2021-02-04 10:37:33 · 671 阅读 · 0 评论