How to check if a sequence is empty in Kotlin

Viewed 1785

How to check if a sequence is empty in Kotlin? What's the simplest way?

2 Answers

If you mean literally a Sequence, use none() without arguments for "is empty" and any() for "is not empty".

For other collections, these method names work as well, but there's also isNotEmpty(). Strangely, there is isEmpty, but only for arrays!

Related