primitive_types2 solution

This commit is contained in:
mo8it 2024-06-08 21:35:44 +02:00
parent 0e4136d31e
commit e1051724c3
3 changed files with 31 additions and 6 deletions

View file

@ -1,3 +1,5 @@
// Booleans (`bool`)
fn main() { fn main() {
let is_morning = true; let is_morning = true;
if is_morning { if is_morning {

View file

@ -1,6 +1,6 @@
fn main() { // Characters (`char`)
// Characters (`char`)
fn main() {
// Note the _single_ quotes, these are different from the double quotes // Note the _single_ quotes, these are different from the double quotes
// you've been seeing around. // you've been seeing around.
let my_first_initial = 'C'; let my_first_initial = 'C';
@ -12,9 +12,12 @@ fn main() {
println!("Neither alphabetic nor numeric!"); println!("Neither alphabetic nor numeric!");
} }
let // Finish this line like the example! What's your favorite character? // TODO: Analogous to the example before, declare a variable called `your_character`
// Try a letter, try a number, try a special character, try a character // below with your favorite character.
// from a different language than your own, try an emoji! // Try a letter, try a digit (in single quotes), try a special character, try a character
// from a different language than your own, try an emoji 😉
// let your_character = '';
if your_character.is_alphabetic() { if your_character.is_alphabetic() {
println!("Alphabetical!"); println!("Alphabetical!");
} else if your_character.is_numeric() { } else if your_character.is_numeric() {

View file

@ -1 +1,21 @@
// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 fn main() {
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!");
}
// Example with an emoji.
let your_character = '🦀';
if your_character.is_alphabetic() {
println!("Alphabetical!");
} else if your_character.is_numeric() {
println!("Numerical!");
} else {
println!("Neither alphabetic nor numeric!");
}
}