method List.get
Element at i or none.
Example:
fn main() io {
var xs = [1, 2, 3]
xs.reverse()
print("{xs}")
}Output
[3, 2, 1]
Example:
fn main() io {
let xs = [1, 2, 3]
print("{xs.contains(2)} {xs.contains(9)}")
}Output
true false
Example:
fn main() io {
var xs = [1, 2, 3]
xs.clear()
print("{xs.len()}")
}Output
0
Example:
fn main() io {
var xs = ["a", "b", "c"]
let b = xs.remove(1)
print("{b} {xs}")
}Output
b ["a", "c"]
Example:
fn main() io {
var xs = [1, 3]
xs.insert(1, 2)
print("{xs}")
}Output
[1, 2, 3]
Example:
fn main() io {
let xs = ["a", "b"]
print("{xs.get(1)} {xs.get(5)}")
}Output
b none
pub(api) fn get(i: usize) -> T?Since. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
i | usize |
Returns
T?
Effects
none declared (pure unless the body says otherwise)
Defined in: std/core/collections.oxl:181