Skip to content

Commit

Permalink
impl Bool: Compare
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasWanke committed Dec 12, 2024
1 parent 3334a92 commit d62f705
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages_v5/example.candy
Original file line number Diff line number Diff line change
Expand Up @@ -558,11 +558,17 @@ fun xor(a: Bool, b: Bool) Bool {
fun implies(a: Bool, b: Bool) Bool {
not(a).or(b)
}
impl Bool: Equal {
fun equals(self: Bool, other: Bool) Bool {
impl Bool: Compare {
fun compareTo(self: Bool, other: Bool) Ordering {
switch self {
true => other,
false => other.not(),
false => switch other {
false => Ordering.equal(),
true => Ordering.less(),
},
true => switch other {
false => Ordering.greater(),
true => Ordering.equal(),
},
}
}
}
Expand Down

0 comments on commit d62f705

Please sign in to comment.