Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Operadores de Atribuição

Usados para atribuir valores a variáveis.

+=

#![allow(unused)]
fn main() {
let mut num: u8 = 10;

num += 1;
println!("10 += 1 = {}", num);
}

-=

#![allow(unused)]
fn main() {
let mut num: u8 = 10;

num -= 1;
println!("10 -= 1 = {}", num);
}

*=

#![allow(unused)]
fn main() {
let mut num: u8 = 10;

num *= 2;
println!("10 *= 2 = {}", num);
}

/=

#![allow(unused)]
fn main() {
let mut num: u8 = 20;

num /= 3;
println!("20 /= 3 = {}", num);
}

%=

#![allow(unused)]
fn main() {
let mut num: u8 = 6;

num %= 4;
println!("6 %= 4 = {}", num);
}