method Map.get
Value for k or none.
Example:
fn main() io {
let m: Map<str, i32> = {"a": 1}
print("{m.values()}")
}Output
[1]
Example:
fn main() io {
let m: Map<str, i32> = {"a": 1}
print("{m.keys()}")
}Output
["a"]
Example:
fn main() io {
var m: Map<str, i32> = {"a": 1}
m.clear()
print("{m.len()}")
}Output
0
Example:
fn main() io {
let m: Map<str, i32> = {"a": 1}
print("{m.contains("a")} {m.contains("b")}")
}Output
true false
Example:
fn main() io {
var m: Map<str, i32> = {"a": 1}
print("{m.remove("a")} {m.remove("a")}")
}Output
1 none
Example:
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:
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
| Name | Type |
|---|---|
k | K |
Returns
V?
Effects
none declared (pure unless the body says otherwise)
Defined in: std/core/collections.oxl:740