1
0
Fork 0
mirror of https://github.com/rust-lang/rustlings.git synced 2024-05-28 18:36:10 +02:00

Start some primitive types exercises

This commit is contained in:
Carol (Nichols || Goulding) 2015-09-18 21:10:16 -04:00
parent 36a75c733e
commit 70f8153ed9
3 changed files with 49 additions and 0 deletions

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,16 @@
// 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() {
// Booleans (`bool`)
let is_morning = true;
if is_morning {
println!("Good morning!");
}
let // Finish the rest of this line like the example! Or make it be false!
if is_evening {
println!("Good evening!");
}
}

View File

@ -0,0 +1,26 @@
// 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`)
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!");
}
}