I was playing around with the allSatisfy(_:)
method on Sequence
and found some unexpected behaviour.
I tried to see what would happen if I used it on an empty array.
var arr = [String]()
print(arr.allSatisfy { $0 is Int })
// Prints "true"
It seems to me that it would make more sense if this returns false
if the sequence is empty because there are no elements to satisfy the given predicate.
Is it worthwhile to add a guard
statement to the declaration of allSatisfy(_:)
in the Standard Library? What do you think should be returned in this case?