2022-08-19 16:25:42 +12:00
|
|
|
use Any
|
|
|
|
use Boolean
|
|
|
|
|
2022-08-04 17:38:00 +12:00
|
|
|
```doc
|
|
|
|
# LogicalOr
|
|
|
|
|
|
|
|
Values which wish to implement the `||` infix operator must implement this protocol.
|
|
|
|
```
|
2022-08-07 16:20:33 +12:00
|
|
|
protocol LogicalOr, as: do
|
2022-08-04 17:38:00 +12:00
|
|
|
```doc
|
|
|
|
Should the value be considered `true` for purposes of an `||` expression?
|
|
|
|
|
|
|
|
Must be implemented.
|
|
|
|
```
|
|
|
|
def true?(self: Self): Boolean
|
|
|
|
|
|
|
|
```doc
|
|
|
|
A short-circuiting logical or operation.
|
|
|
|
|
|
|
|
If `LogicalOr.true?` is true for the left-hand value then it is returned, otherwise the right-hand value is returned.
|
|
|
|
```
|
2022-08-19 17:46:36 +12:00
|
|
|
def or(self: Self, _other: Any): Any, when: true?(self), as: self
|
|
|
|
def or(_self: Self, other: Any): Any, as: other
|
2022-08-04 17:38:00 +12:00
|
|
|
end
|