Skip to content

Commit 57bbbd9

Browse files
ubaidskcertik
authored andcommitted
lpython.py: Support __bool__() for UnsignedInteger
1 parent 1198a3d commit 57bbbd9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/runtime/lpython/lpython.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ def __init__(self, bit_width, value):
2626
self.bit_width = bit_width
2727
self.value = value
2828

29+
def __bool__(self):
30+
return self.value != 0
31+
2932
def __add__(self, other):
3033
if isinstance(other, self.__class__):
3134
return UnsignedInteger(self.bit_width, (self.value + other.value) % (2**self.bit_width))

0 commit comments

Comments
 (0)