OxL Reference

method Map.get

Value for k or none.

Example:

oxl✓ checked in CI
fn main() io {
  let m: Map<str, i32> = {"a": 1}
  print("{m.values()}")
}
Output
[1]

Example:

oxl✓ checked in CI
fn main() io {
  let m: Map<str, i32> = {"a": 1}
  print("{m.keys()}")
}
Output
["a"]

Example:

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

Example:

oxl✓ checked in CI
fn main() io {
  let m: Map<str, i32> = {"a": 1}
  print("{m.contains("a")} {m.contains("b")}")
}
Output
true false

Example:

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

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

Example:

oxl✓ checked in CI
fn main() io {
  let m: Map<str, i32> = {"a": 1}
  print("{m.get("a")} {m.get("z")}")
}
Output
1 none
pub(api) fn get(k: K) -> V?

Since. 1.0.0-beta

Parameters

NameType
kK

Returns

V?

Effects

none declared (pure unless the body says otherwise)

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

See also