update variables with type indication and added data types
This commit is contained in:
@@ -2,14 +2,15 @@
|
|||||||
const NAME : &str = "John";
|
const NAME : &str = "John";
|
||||||
const HEX_NUM : &i32 = &0x01;
|
const HEX_NUM : &i32 = &0x01;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// local variables dont need a type indication and are by default immutable
|
// local variables dont need a type indication and are by default immutable
|
||||||
let local_name = "Dough";
|
let local_name: &str = "Dough"; // must be surrounded by double quotes
|
||||||
let normal_int = 35;
|
let normal_int: i32 = 35;
|
||||||
let hex_int = 0x35;
|
let hex_int: i32 = 0x35;
|
||||||
let bin_int = 0b10101111;
|
let bin_int: i32 = 0b10101111;
|
||||||
|
let height: f64 = 1.79;
|
||||||
|
let character: char = 'M';
|
||||||
|
let has_driver_license: bool = true;
|
||||||
|
|
||||||
//make them mutable by mut modifier
|
//make them mutable by mut modifier
|
||||||
let mut middle_name = "Levy";
|
let mut middle_name = "Levy";
|
||||||
@@ -18,6 +19,9 @@ fn main() {
|
|||||||
|
|
||||||
println!("name: {} {} {}",NAME,middle_name, local_name);
|
println!("name: {} {} {}",NAME,middle_name, local_name);
|
||||||
println!("age: {}", normal_int);
|
println!("age: {}", normal_int);
|
||||||
|
println!("gender: {}",character);
|
||||||
|
println!("has driver license: {}",has_driver_license);
|
||||||
|
println!("height: {}",height);
|
||||||
println!("hex: {}",hex_int);
|
println!("hex: {}",hex_int);
|
||||||
println!("const hex: {}",HEX_NUM);
|
println!("const hex: {}",HEX_NUM);
|
||||||
println!("binary: {}",bin_int);
|
println!("binary: {}",bin_int);
|
||||||
|
|||||||
Reference in New Issue
Block a user