Jump to content

Rust (programming language): Difference between revisions

No edit summary
Line 20: Line 20:
   # Shadowing, creating a new variable.
   # Shadowing, creating a new variable.
   let x = x + 5;
   let x = x + 5;
 
 
   # Loop over values [0, 1, 2]
   # Loop over values [0, 1, 2]
   for i in 0..3 {
   for i in 0..3 {
     println!("This number is {}", i);
     println!("This number is {}", i);
   }
   }
 
 
   # Ternary is a single line if statement.
   # Ternary is a single line if statement.
   let big_x = if x > 5 {x} else {5};
   let big_x = if x > 5 {x} else {5};