Note about all() result on empty collections KT-54835

This commit is contained in:
Ilya Gorbunov
2022-11-24 21:48:57 +01:00
committed by Space Team
parent 77e03bb769
commit 0d0cc9250b
7 changed files with 73 additions and 1 deletions
@@ -157,6 +157,10 @@ public inline fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.mapTo(des
/**
* Returns `true` if all entries match the given [predicate].
*
* Note that if the map contains no entries, the function returns `true`
* because there are no entries in it that _do not_ match the predicate.
* See a more detailed explanation of this logic concept in ["Vacuous truth"](https://en.wikipedia.org/wiki/Vacuous_truth) article.
*
* @sample samples.collections.Collections.Aggregates.all
*/
public inline fun <K, V> Map<out K, V>.all(predicate: (Map.Entry<K, V>) -> Boolean): Boolean {