Created
March 27, 2022 06:13
-
-
Save jcar787/3809a1231b345ccb8e0977ed33bd1b2c to your computer and use it in GitHub Desktop.
Primitive Types - Scalars
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
// The next 6 lines are immutable variables | |
let an_int = 35; // Default is i32 | |
let another_int: u16 = 35_633; | |
let a_float: f32 = 2.56; | |
let another_float = 2.03_f64; | |
let my_bool = true; | |
let my_char = 'j'; | |
println!("{}", an_int); | |
println!("{}", another_int); | |
println!("{}", a_float); | |
println!("{}", another_float); | |
println!("{}", my_bool); | |
println!("{}", my_char); | |
// This one is mutable | |
let mut an_int_m = 56; | |
println!("Before: {}", an_int_m); | |
an_int_m += 25; | |
println!("After: {}", an_int_m); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment