Skip to content

Instantly share code, notes, and snippets.

@islandjoe
Created May 30, 2020 06:51
Show Gist options
  • Save islandjoe/9eb313bde4450ec1392488883144f59c to your computer and use it in GitHub Desktop.
Save islandjoe/9eb313bde4450ec1392488883144f59c to your computer and use it in GitHub Desktop.
Rust: Print name if it starts with 'A'
```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