OxL Reference

method TVar.update

set(f(get())).

Example:

oxl✓ checked in CI
use std.stm { TVar }

fn main() io {
  let v = TVar<i32>.new(10)
  atomic { v.update(x => x + 5) }
  print("{atomic { v.get() }}")
}
Output
15
pub(api) fn update(f: fn(T) -> T)

Since. 1.0.0-beta

Parameters

NameType
ffn(T) -> T

Effects

none declared (pure unless the body says otherwise)

Defined in: std/stm/stm.oxl:123

See also