outrun/outrun-core/lib/logical_or.run

22 lines
588 B
Text
Raw Normal View History

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.
```
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