Skip to content

Commit e105172

Browse files
committed
primitive_types2 solution
1 parent 0e4136d commit e105172

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

exercises/04_primitive_types/primitive_types1.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Booleans (`bool`)
2+
13
fn main() {
24
let is_morning = true;
35
if is_morning {

exercises/04_primitive_types/primitive_types2.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
fn main() {
2-
// Characters (`char`)
1+
// Characters (`char`)
32

3+
fn main() {
44
// Note the _single_ quotes, these are different from the double quotes
55
// you've been seeing around.
66
let my_first_initial = 'C';
@@ -12,9 +12,12 @@ fn main() {
1212
println!("Neither alphabetic nor numeric!");
1313
}
1414

15-
let // Finish this line like the example! What's your favorite character?
16-
// Try a letter, try a number, try a special character, try a character
17-
// from a different language than your own, try an emoji!
15+
// TODO: Analogous to the example before, declare a variable called `your_character`
16+
// below with your favorite character.
17+
// Try a letter, try a digit (in single quotes), try a special character, try a character
18+
// from a different language than your own, try an emoji 😉
19+
// let your_character = '';
20+
1821
if your_character.is_alphabetic() {
1922
println!("Alphabetical!");
2023
} else if your_character.is_numeric() {
Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,21 @@
1-
// Solutions will be available before the stable release. Thank you for testing the beta version 🥰
1+
fn main() {
2+
let my_first_initial = 'C';
3+
if my_first_initial.is_alphabetic() {
4+
println!("Alphabetical!");
5+
} else if my_first_initial.is_numeric() {
6+
println!("Numerical!");
7+
} else {
8+
println!("Neither alphabetic nor numeric!");
9+
}
10+
11+
// Example with an emoji.
12+
let your_character = '🦀';
13+
14+
if your_character.is_alphabetic() {
15+
println!("Alphabetical!");
16+
} else if your_character.is_numeric() {
17+
println!("Numerical!");
18+
} else {
19+
println!("Neither alphabetic nor numeric!");
20+
}
21+
}

0 commit comments

Comments
 (0)