Created
April 5, 2016 01:43
-
-
Save kscz/7543754b36cf5995cbf54d4e14b28b6b 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() { | |
println!("Hello darkness my old {}", pick_one(true, "friend", "frenemy")); | |
println!("I've come to {} with you again.", pick_one(false, "dance", "talk")); | |
println!("Because a {} softly creeping", pick_one(false, "gremlin", "vision")); | |
println!("Left its {} while I was {}.", pick_one(true, "seeds", "cell phone"), pick_one(false, "also creeping", "sleeping")); | |
} | |
fn pick_one<'a>(this_or_that: bool, this: &'a str, that: &'a str) -> &'a str { | |
if this_or_that { | |
this | |
} else { | |
that | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment