<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/FlattenSequence/Iterator/allSatisfy(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:STsE10allSatisfyyS2b7ElementQzKXEKF::SYNTHESIZED::s:s15FlattenSequenceV8IteratorV"
  },
  "title" : "allSatisfy(_:)"
}
-->

# allSatisfy(_:)

Returns a Boolean value indicating whether every element of a sequence
satisfies a given predicate.

```
func allSatisfy(_ predicate: (Self.Element) throws -> Bool) rethrows -> Bool
```

## Parameters

`predicate`

A closure that takes an element of the sequence
as its argument and returns a Boolean value that indicates whether
the passed element satisfies a condition.

## Return Value

`true` if the sequence contains only elements that satisfy
`predicate`; otherwise, `false`.

## Discussion

The following code uses this method to test whether all the names in an
array have at least five characters:

```
let names = ["Sofia", "Camilla", "Martina", "Mateo", "Nicolás"]
let allHaveAtLeastFive = names.allSatisfy({ $0.count >= 5 })
// allHaveAtLeastFive == true
```

If the sequence is empty, this method returns `true`.

> Complexity: O(*n*), where *n* is the length of the sequence.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)