Last active
August 29, 2015 14:02
-
-
Save gilles-leblanc/e07cf10af136c41f37e7 to your computer and use it in GitHub Desktop.
Rust: expressions
This file contains 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
// expressions.rs | |
fn main() { | |
let a = { | |
let inner = 2; | |
inner * inner | |
}; | |
println!("a = {}", a); | |
let b = { | |
let inner = 2; | |
inner * inner; | |
}; | |
println!("b = {}", b); | |
println!("{}", returns_hello()); | |
let bool_value = true; | |
let int_value = | |
if bool_value == true { | |
1 | |
} else { | |
0 | |
}; | |
println!("{}", int_value); | |
} | |
fn returns_hello() -> String { | |
String::from_str("hello") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment