This repository has been archived on 2023-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
2018-02-22 00:09:53 -06:00
|
|
|
// primitive_types2.rs
|
2015-09-18 20:10:16 -05:00
|
|
|
// Fill in the rest of the line that has code missing!
|
|
|
|
// No hints, there's no tricks, just get used to typing these :)
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
// Characters (`char`)
|
|
|
|
|
2022-07-12 07:54:12 -05:00
|
|
|
// Note the _single_ quotes, these are different from the double quotes
|
|
|
|
// you've been seeing around.
|
2015-09-18 20:10:16 -05:00
|
|
|
let my_first_initial = 'C';
|
|
|
|
if my_first_initial.is_alphabetic() {
|
|
|
|
println!("Alphabetical!");
|
|
|
|
} else if my_first_initial.is_numeric() {
|
|
|
|
println!("Numerical!");
|
|
|
|
} else {
|
|
|
|
println!("Neither alphabetic nor numeric!");
|
|
|
|
}
|
|
|
|
|
2023-03-24 16:18:51 -05:00
|
|
|
let your_character = '🔥'; // Finish this line like the example! What's your favorite character?
|
|
|
|
// Try a letter, try a number, try a special character, try a character
|
|
|
|
// from a different language than your own, try an emoji!
|
2015-09-18 20:10:16 -05:00
|
|
|
if your_character.is_alphabetic() {
|
|
|
|
println!("Alphabetical!");
|
|
|
|
} else if your_character.is_numeric() {
|
|
|
|
println!("Numerical!");
|
|
|
|
} else {
|
|
|
|
println!("Neither alphabetic nor numeric!");
|
|
|
|
}
|
|
|
|
}
|