OxL Reference

5.4 Conditions

oxl
let kind = if n < 0 { "neg" } else if n == 0 { "zero" } else { "pos" }
if let User{ role: .Admin, name, .. } = u { greet(name) }
if x is Receipt { save(x) }          // x is narrowed to Receipt

There is no ternary operator. An if without else has type ().

  • The type of if/match is the common expected type if the context gives one, otherwise the union of the branch types (if c { s } else { EmptyCart{} } has type CartSnapshot | EmptyCart).
  • e is P — a check against pattern P (§5.5) as a boolean expression. The pattern bindings are visible in the if branch and in the right-hand part of &&: if caller is .User(id: uid, ..) && uid == owner { … }. An enum variant in is is written with a dot (.User) so as not to confuse it with a type.

See also

Source: docs/spec/oxl-standard.en.md