println!
Try it yourself →Writes values and moves to a new line.
Syntax
println!("{}", value)Description
It is a macro (with !). A value goes into the {} placeholder. {:?} is the 'debug' format (for arr/struct).
Example
fn main() {
println!("Hello World");
println!("{} + {} = {}", 2, 3, 2 + 3);
}Expected output
Hello World 2 + 3 = 5
When to use?
Showing results, debugging.
Common mistakes
- ⚠️ The ! at the end of println! (macro indicator) is mandatory.