Skip to content

Instantly share code, notes, and snippets.

@freeformz
Created September 20, 2014 03:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save freeformz/95da374193583ba64e56 to your computer and use it in GitHub Desktop.
Save freeformz/95da374193583ba64e56 to your computer and use it in GitHub Desktop.
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);
}
test assign w/semi: muffin item
test direct assign w/semi: ()
test direct assign w/o semi: muffin item
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment