rust变量与可变性
fn main() { //let x = 5; let mut x = 5; //通过const定义常量名称要大写,并且值不可更改 const Y:i32=6; println!("Y is {}",Y); println!("The value of x is {}", x); x = 6; println!("The value of x is {}", x); //如果要覆盖上一个变量 需要使用let //如果不是let而改变了x的类型会出错 //x = 1.23; let x = "hello"; println!("x type changed to string ,{}",x); let x = x.len(); println!("x len is {}",x) }
相关推荐
zhangxiafll 2020-11-13
svap 2020-11-09
viplinux 2020-10-28
Justhavefun 2020-10-22
lousir 2020-10-21
longzhiwen 2020-10-16
Justhavefun 2020-09-25
归去来兮 2020-09-18
zhouxiaojie 2020-09-16
gamedevd 2020-09-04
tkernel 2020-09-03
Trustport 2020-09-01
svap 2020-08-25
tkernel 2020-08-18
lihn 2020-08-18
归去来兮 2020-07-28
TianlangStudio 2020-07-18
iammjun 2020-07-07
Colourful 2020-07-03