outrun/outrun-core/lib/logical_or.outrun

25 lines
617 B
Text
Raw Permalink Normal View History

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.
```
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-22 11:30:39 +12:00
def or(self: Self, _other: Any): Any, when: LogicalOr.true?(self), as: self
def or(_self: Self, other: Any): Any, as: other
2022-08-04 17:38:00 +12:00
end