Last active
February 7, 2019 14:55
-
-
Save sisoje/b72c003300f0693c2e419c9a1683d38d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Person { | |
let name: String | |
let age: Int | |
} | |
struct Payment { | |
let currency: String | |
let amount: Double | |
} | |
// persons named John older than 18 | |
let predicate1 = \Person.name == "John" && \Person.age >= 18 | |
// payments in EUR, USD or GBP greater than 1000 | |
let predicate2 = \Payment.currency === ["EUR", "USD", "GBP"] && \Payment.amount > 1000 | |
// doesn't compile - value type does not match | |
let predicate3 = \Payment.currency == 1000 | |
// doesn't compile - root type between predicates does not match | |
let predicate4 = \Payment.currency == "EUR" && \Person.age >= 30 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment