...

/

Solution Review: Defining Variables

Solution Review: Defining Variables

This lesson gives a detailed solution review of the challenge in the previous lesson.

We'll cover the following...

Solution:

Press + to interact
fn test() {
// declare a mutable variable `x`
let mut x = 1000;
// declare a variable `y`
let y="Programming";
// print output of `x`
println!("x:{}", x);
// print output of `y`
println!("y:{}", y);
// update x
x = 1100;
// print output of `x`
println!("x:{}", x);
// print output of `y`
println!("y:{}", y);
}

Explanation

  • On line 3, a mutable variable x is defined and assigned the
...