OxL Reference

method Map.insert

Stores v under k, replacing the value that was there.

Example:

oxl✓ checked in CI
fn main() io {
  var m: Map<str, i32> = {:}
  m.insert("a", 1)
  m.insert("a", 2)
  print("{m.get("a")} {m.len()}")
}
Output
2 1

Inserts or replaces the value of k.

Example:

oxl✓ checked in CI
fn main() io {
  var m: Map<str, i32> = {:}
  m.insert("a", 1)
  m.insert("a", 2)
  print("{m.get("a")} {m.len()}")
}
Output
2 1
pub(api) var fn insert(k: K, v: V)

Complexity. O(1) on average.

Since. 1.0.0-beta

Parameters

NameType
kK
vV

Effects

none declared (pure unless the body says otherwise)

Defined in: std/core/collections.oxl:771

See also