如何检查 Kotlin 中的序列是否为空

How to check if a sequence is empty in Kotlin

Kotlin中如何判断一个序列是否为空?最简单的方法是什么?

!sequence.iterator().hasNext()

如果您的意思是 Sequence,请使用 none() without arguments for "is empty" and any() 表示 "is not empty"。

对于其他集合,这些方法名称也适用,但也有 isNotEmpty(). Strangely, there is isEmpty, but only for arrays!