Created
December 1, 2022 16:00
-
-
Save RGGH/4a4335b92048ad39ce2fff872084e6e9 to your computer and use it in GitHub Desktop.
Update Array from a Function - Rust
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let mut arr: [i32; 4] = [1, 2, 3, 4]; | |
change_value(&mut arr); | |
for x in arr { | |
print!("{} ", x); | |
} | |
} | |
fn change_value(arr: &mut [i32]) { | |
arr[1] = 10; | |
arr[2] = 20; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment