Variables

We'll cover the following...

Often, we don’t want to put all of the values we care about on one line like that. It can be more pleasant to define variables, which are convenient names that refer to the values we care about. We do that with let:

Press + to interact
fn main() {
let name = "Michael";
println!("My name is {}", name);
}

Now, name is pointing at the string "Michael", and we can refer to that when we call println! ...

Access this course and 1400+ top-rated courses and projects.