Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

copy an array

// Copy an array
fn main() {
    let arr = ["a","b","c"];
    let mut another = arr.clone();  // make a copy
    println!("copy of arr = {:?} ", another);
    another[1] = "d";          // make a change
    assert_eq!(arr, another);  // panic, no longer equal
}
Source by www.samanthaming.com #
 
PREVIOUS NEXT
Tagged: #copy #array
ADD COMMENT
Topic
Name
9+5 =