From 6e996195ff12db90b00737060425dec5d43c1829 Mon Sep 17 00:00:00 2001 From: Noah Kamara <40308075+NoahKamara@users.noreply.github.com> Date: Sat, 23 Mar 2024 14:03:16 +0100 Subject: [PATCH] Update README.md --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 590131b..4cf680a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,21 @@ [![Build & Test](https://github.com/NoahKamara/CompoundPredicate/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/NoahKamara/CompoundPredicate/actions/workflows/build-and-test.yml) +## For Developers targeting macOS 14.4 / iOS 17.4 or later: + +This [PR](https://github.com/apple/swift-foundation/pull/343) For Swift Foundation adds compound functionality to Predicates like so: +If you are targeting only those versions and above you should use this instead: + +```swift +let notTooShort = #Predicate { $0.pages > 50 } +let notTooLong = #Predicate { $0.pages <= 350 } +let titleFilter = #Predicate { $0.title.contains("Swift") } + +let filter = #Predicate { + (notTooShort.evaluate($0) && notTooLong.evaluate($0)) || titleFilter.evaluate($0) +} +``` + + # CompoundPredicate CompoundPredicate aims to improve the Predicate system to enable combining multiple predicates after constructing them: