Home / Docs / Standard library / Prelude

is_some

Release v0.4.0Edition 0.1 and later

A function of the prelude, in scope in every module. Edition 0.1 and later.

una
pub is_some[T](o: Option[T]) -> Bool
  ensures result == (o is Some)

Whether o is Some (spec/14 §1).

Parameters

Returns

Bool: true exactly when o is Some.

See also

Option, or_else

Example

src/shop.unauna
module shop

--- Whether a cart has a first item.
pub main() -> Unit
  uses @console: Console[print]
=
  let some = ["lamp"].first().is_some()
  @console.print("has an item: {some}")

una run . prints:

Output
has an item: true

Specification

Generated from the standard modules of una v0.4.0 (docs/std/listing.json, which is not part of the specification). The specification governs: spec/14 §1.