Last active
August 29, 2015 14:06
-
-
Save freeformz/b8c0c4aeb96cfb6237a2 to your computer and use it in GitHub Desktop.
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
fn main() { | |
let item = "muffin"; | |
let thing1; | |
if item == "salad" { | |
thing1 = "salad item"; | |
} else if item == "muffin" { | |
thing1 = "muffin item"; | |
} else { | |
thing1 = "other item"; | |
} | |
println!("test assign w/semi: {}", thing1); | |
let thing2 = | |
if item == "salad" { | |
"salad item"; | |
} else if item == "muffin" { | |
"muffin item"; | |
} else { | |
"other item"; | |
}; | |
println!("test direct assign w/semi: {}", thing2); | |
let thing3 = | |
if item == "salad" { | |
"salad item" | |
} else if item == "muffin" { | |
"muffin item" | |
} else { | |
"other item" | |
}; | |
// | |
println!("test direct assign w/o semi: {}", thing3) | |
match item { | |
"salad" => { println!("test match: salad item") } | |
"muffin" => println!("test match: muffin item"), | |
_ => println!("test match: other item") | |
} | |
} |
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
test assign w/semi: muffin item | |
test direct assign w/semi: () | |
test direct assign w/o semi: muffin item | |
test match: muffin item |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment