outrun/outrun-core/lib/logical_or.outrun

24 lines
617 B
Text

use Any
use Boolean
```doc
# LogicalOr
Values which wish to implement the `||` infix operator must implement this protocol.
```
protocol LogicalOr, as: do
```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(self: Self, _other: Any): Any, when: LogicalOr.true?(self), as: self
def or(_self: Self, other: Any): Any, as: other
end