outrun/lib/greater_or_equal.run

18 lines
825 B
Text
Raw Normal View History

2022-08-04 17:38:00 +12:00
```doc
# GreaterOrEqual
Values which implement the `>=` infix operator must implement this protocol.
If the value also implements the `Greater` and `Equality` protocols then this protocol can be automatically implemented.
```
protocol GreaterOrEqual, requires: Greater + Equality, as: do
2022-08-04 17:38:00 +12:00
```doc
Compare `self` and `other` returning a boolean.
2022-08-04 17:38:00 +12:00
The default implementation delegates to the `Greater` and `Equality` protocols, however you should probably implement this function as a single comparison is more than likely much faster.
```
def greater_or_equal?(self: Greater, other: Any): Boolean, when: Greater.greater?(self, other), as: true
def greater_or_equal?(self: Equality, other: Any): Boolean, when: Equality.equal?(self, other), as: true
def greater_or_equal?(_self: Self, _other: Any), as: false
end