如何使用下一个值作为集合的 zipWithNext 运算符压缩流?
zipWithNext 的行为类似于:
val letters = ('a'..'f').toList()
val pairs = letters.zipWithNext()
println(letters) // [a, b, c, d, e, f]
println(pairs) // [(a, b), (b, c), (c, d), (d, e), (e, f)]
但在我的情况下,字母是:
val letters = flowOf('a'..'f')
奖励积分:
flowOf(1, 2, 3).scan(emptyList<Int>()) { acc, value -> acc + value }.toList()
我在https://play.kotlinlang.org/上试过,但没有找到flowOf
什么导入,否则我在那里失踪了?