Skip to content

Commit

Permalink
Add __bool__.
Browse files Browse the repository at this point in the history
  • Loading branch information
salt-die committed Dec 5, 2023
1 parent e65d21d commit b6464d3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/mind_the_gaps/gaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ def __xor__(self, other: Self) -> Self:
def __sub__(self, other: Self) -> Self:
return Gaps(_merge(self.endpoints, other.endpoints, sub))

def __bool__(self):
return len(self.endpoints) > 0

def __contains__(self, value: T) -> bool:
i = bisect(self.endpoints, value, key=attrgetter("value"))
if i == 0:
Expand Down

0 comments on commit b6464d3

Please sign in to comment.