method List.clone
A copy of the list (elements are cloned too).
Example:
fn main() io {
let a = [1, 2]
var b = a.clone()
b.push(3)
print("{a} {b}")
}Output
[1, 2] [1, 2, 3]
A copy of the list; the original stays usable.
Example:
fn main() io {
let a = [1, 2]
var b = a.clone()
b.push(3)
print("{a} {b}")
}Output
[1, 2] [1, 2, 3]
pub(api) fn clone() -> List<T>Complexity. O(n).
Since. 1.0.0-beta
Returns
List<T>
Effects
none declared (pure unless the body says otherwise)
Defined in: std/core/collections.oxl:394