OxL Справочник OxL
РусскийEnglish

op |

|

Определяется в

Примеры

oxl
operator <|> <T>(a: Parser<T>, b: Parser<T>) -> Parser<T>  infixl 3 => a.orElse(b)
operator ~~ (s: str, re: Regex) -> bool                      infix 4 => re.matches(s)
operator ^^ (a: f64, b: f64) -> f64                          infixr 12 => a.pow(b)
operator ¬ (b: Bits) -> Bits                                prefix => b.invert()

— 5.3 Перегрузка и пользовательские операторы

oxl
@error data NotFound { what: str }
@error enum PayError { Declined(reason: str), Fraud }

fn charge(card: Card, sum: Money) -> Receipt | PayError | NetError  net {
  let token = Vault.tokenize(card)?          // ? пробрасывает ошибки вызова
  if sum <= Money.zero() { fail PayError.Declined("zero sum") }
  Bank.pay(token, sum)
}

— 6.5 Ошибки

Связанные диагностики

chained-comparison, not-callable, not-overloadable, operator-decl, range-not-iterable, invalid-char, task-reuse, fail-type, question-context, unhandled-error, type-mismatch

См. также