In this lesson we take a look at how println!() can be used to output multiple variables using formatter placeholders.
Instructor: To output multiple variables, println supports multiple placeholders as well. If we have variable name and another name, we can use println, placeholder, some string and another placeholder, and then pass it the first variable and then the second variable.
When this code runs, Rust will replace the first variable with the first placeholder and the second variable with the second placeholder. This can be done with as many placeholders as we need.
We save the file and run the program using cargo run. We will see that it will output has kind of end of this.
You must be a Pro Member to view code
Access all courses and lessons, track your progress, gain confidence and expertise.