Home / Docs / Standard library / Prelude
is_empty
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_empty[T](xs: List[T]) -> Bool
ensures result == (xs.len == 0)Whether xs has no elements (spec/14 §1).
Parameters
xs: the list
Returns
Bool: true exactly when xs.len == 0.
Example
src/shop.una
module shop
--- Whether a cart has anything in it.
pub main() -> Unit
uses @console: Console[print]
=
let cart: List[Text] = []
let empty = cart.is_empty()
@console.print("empty: {empty}")una run . prints:
Output
empty: trueSpecification
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.