17 lines
801 B
Text
17 lines
801 B
Text
```doc
|
|
# LessOrEqual
|
|
|
|
Values which implement the `<=` infix operator must implement this protocol.
|
|
|
|
If the value also implements the `Less` and `Equality` protocols then this protocol can be automatically implemented.
|
|
```
|
|
protocol LessOrEqual, requires: Less + Equality, as: do
|
|
```doc
|
|
Compare `self` and `other` returning a boolean.
|
|
|
|
The default implementation delegates to the `Less` and `Equality` protocols, however you should probably implement this function as a single comparison is more than likely much faster.
|
|
```
|
|
def less_or_equal?(self: Less, other: Any): Boolean, when: Less.less?(self, other), as: true
|
|
def less_or_equal?(self: Equality, other: Any): Boolean, when: Equality.equal?(self, other), as: true
|
|
def less_or_equal?(_self: Self, _other: Any): Boolean, as: false
|
|
end
|