Reputation: 1859
How to check if a sequence is empty in Kotlin? What's the simplest way?
Upvotes: 8
Views: 3913
Reputation: 170745
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!
Upvotes: 17