From c7219b22904e7427d63e1ac6b08374d757190cba Mon Sep 17 00:00:00 2001 From: dcodesdev <101001810+dcodesdev@users.noreply.github.com> Date: Mon, 13 Jan 2025 10:09:46 +0300 Subject: [PATCH] declaring vars --- .../primitive-data-types/description.md | 29 ++++++++++--------- .../primitive-data-types/src/starter.rs | 2 +- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/challenges/primitive-data-types/description.md b/challenges/primitive-data-types/description.md index 2ad86b9..07c4589 100644 --- a/challenges/primitive-data-types/description.md +++ b/challenges/primitive-data-types/description.md @@ -4,17 +4,11 @@ Understanding how to declare and use these basic data types is fundamental to wr ## Your task -1. Define variable `x` with type `u8` -2. Define variable `y` with type `f64` -3. Define variable `z` with type `bool` -4. Define variable `a` with type `char` - -Each of these variables **should be annotated** with their respective types and initialized with specific **values of your choice**. - -## Requirements - -- Every variable **must be annotated** with its type. -- Initialize each variable with any value of your choice of the correct type. +1. Define a variable with type `u8` and value `42` +2. Define variable with type `f64` and value `3.14` +3. Define variable with type `bool` and value `false` +4. Define variable with type `char` and value `a` +5. In the end, return the tuple `(u8, f64, bool, char)` with the variables you defined. ## Explanation of Data Types @@ -25,5 +19,14 @@ Each of these variables **should be annotated** with their respective types and ## Hints -- Use the `let` keyword to define a variable. -- Annotate the variable's type by specifying `let variable_name: type = `. +Here are some hints for you if you're stuck: + +
+ Click to show hints + +- To define a variable of type `u8` you can use the syntax `let variable_name: u8 = 10;` +- To define a variable of type `f64` you can use the syntax `let variable_name = 3.14;` +- To define a variable of type `bool` you can use the syntax `let variable_name = false;` +- To define a variable of type `char` you can use single quotes like `let variable_name = 'a';` + +
diff --git a/challenges/primitive-data-types/src/starter.rs b/challenges/primitive-data-types/src/starter.rs index eeae17b..6193002 100644 --- a/challenges/primitive-data-types/src/starter.rs +++ b/challenges/primitive-data-types/src/starter.rs @@ -5,7 +5,7 @@ pub fn data_types() -> (u8, f64, bool, char) { // 3. Define variable of type `bool` and value `false` - // 4. Define variable of type `char` and value `'a'` + // 4. Define variable of type `char` and value `a` // 5. Return a tuple with the variables in the order they were defined }