<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/PredicateExpression",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation19PredicateExpressionP"
  },
  "title" : "PredicateExpression"
}
-->

# PredicateExpression

A component expression that makes up part of a predicate.

```
protocol PredicateExpression<Output>
```

## Overview

To transform a predicate, define a protocol for the result and add conformance on each predicate expression type that you support. For example:

```swift
protocol ProsePredicateExpression {
    func proseQuery() -> String
}

// Repeated for each supported operator.
extension PredicateExpressions.Equal: ProsePredicateExpression 
        where LHS: ProsePredicateExpression,
        RHS: ProsePredicateExpression {
    func proseQuery() -> String {
        return lhs.proseQuery() + " is equal to " + rhs.proseQuery()
    }
}

extension Predicate  {
    func proseQuery() -> String? {
        guard let expression = expression as? ProsePredicateExpression else { return nil }
        return expression.proseQuery()
    }
}
```

## Topics

### Evaluating a predicate expression

[`Output`](/documentation/Foundation/PredicateExpression/Output)

[`evaluate(_:)`](/documentation/Foundation/PredicateExpression/evaluate(_:))



---

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)