2018-02-22 06:09:53 +00:00
|
|
|
// primitive_types2.rs
|
2023-05-29 17:39:08 +00:00
|
|
|
//
|
|
|
|
// Fill in the rest of the line that has code missing! No hints, there's no
|
|
|
|
// tricks, just get used to typing these :)
|
2015-09-19 01:10:16 +00:00
|
|
|
|
2019-11-11 12:38:24 +00:00
|
|
|
// I AM NOT DONE
|
|
|
|
|
2015-09-19 01:10:16 +00:00
|
|
|
fn main() {
|
|
|
|
// Characters (`char`)
|
|
|
|
|
2022-07-12 12:54:12 +00:00
|
|
|
// Note the _single_ quotes, these are different from the double quotes
|
|
|
|
// you've been seeing around.
|
2015-09-19 01:10:16 +00: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!");
|
|
|
|
}
|
|
|
|
|
|
|
|
let // 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!
|
|
|
|
if your_character.is_alphabetic() {
|
|
|
|
println!("Alphabetical!");
|
|
|
|
} else if your_character.is_numeric() {
|
|
|
|
println!("Numerical!");
|
|
|
|
} else {
|
|
|
|
println!("Neither alphabetic nor numeric!");
|
|
|
|
}
|
|
|
|
}
|