Created
May 30, 2020 06:51
-
-
Save islandjoe/9eb313bde4450ec1392488883144f59c to your computer and use it in GitHub Desktop.
Rust: Print name if it starts with 'A'
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
```rust | |
use std::env::args; | |
fn main() { | |
for name in args() { | |
if let Some(char_1) = name.chars().next() { | |
match char_1 { | |
'A' => println!("Hello, {}!", name), | |
_ => {} | |
} | |
} | |
} | |
} | |
``` | |
```sh | |
$ cargo run -- Arthur Brendo Cathy | |
Hello, Arthur! | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment