22 lines
575 B
Text
22 lines
575 B
Text
|
```doc
|
||
|
# LogicalOr
|
||
|
|
||
|
Values which wish to implement the `||` infix operator must implement this protocol.
|
||
|
```
|
||
|
protocol LogicalOr, as:
|
||
|
```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.
|
||
|
```
|
||
|
def or?(lhs: Self, _rhs: Any): Any, when: true?(lhs), as: lhs
|
||
|
def or?(_lhs: Self, rhs: Any): Any, as: rhs
|
||
|
end
|