method Map.insert
Stores v under k, replacing the value that was there.
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
Inserts or replaces the value of k.
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
pub(api) var fn insert(k: K, v: V)Complexity. O(1) on average.
Since. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
k | K |
v | V |
Effects
none declared (pure unless the body says otherwise)
Defined in: std/core/collections.oxl:771