added notEmpty() helper method as its very common to want to do something if a collection is not empty; so if (foo.notEmpty()) is easier to read than if (!foo.isEmpty())

This commit is contained in:
James Strachan
2012-02-23 09:24:24 +00:00
parent f35c8926b3
commit cd70f06203
2 changed files with 6 additions and 0 deletions
+3
View File
@@ -8,3 +8,6 @@ inline fun <T, R> java.util.Collection<T>.map(result: Collection<R> = ArrayList<
result.add(transform(item))
return result
}
/** Returns true if the collection is not empty */
inline fun <T> java.util.Collection<T>.notEmpty() : Boolean = !this.isEmpty()