<!--
{
  "availability" : [
    "Xcode: 27.0.0 -",
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Evaluations",
  "identifier" : "/documentation/Evaluations/Evaluator/init(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Evaluations"
    ],
    "preciseIdentifier" : "s:11Evaluations9EvaluatorVyACyxGAA6MetricVx_AA12ModelSubjectVy13ExpectedValueQzGtYaKYCccfc"
  },
  "title" : "init(_:)"
}
-->

# init(_:)

Creates an evaluator with the given evaluation closure.

```
init(_ evaluate: nonisolated(nonsending) @escaping (Input, ModelSubject<Input.ExpectedValue>) async throws -> Metric)
```

## Parameters

`evaluate`

A closure that receives the input and subject,
and returns a [`Metric`](/documentation/Evaluations/Metric) with a result value.

## Discussion

```swift
let metric = Metric("ExactMatch")
let evaluator = Evaluator<ModelSample<String>> { sample, subject in
    guard let expected = sample.expected else { return metric.ignore() }
    return subject.value == expected ? metric.passing() : metric.failing()
}
```

---

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)