Created
December 22, 2021 18:19
-
-
Save mystal/79d6d74f508e9a0ab875a46c7a50c972 to your computer and use it in GitHub Desktop.
Print odd number arguments
This file contains hidden or 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
use std::env; | |
fn main() { | |
let odds: Vec<_> = env::args() | |
.skip(1) | |
.map(|s| s.parse::<i32>().unwrap()) | |
.filter(|&n| n % 2 != 0) | |
.collect(); | |
println!("odd numbers: {:?}", odds); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment