Skip to content

Instantly share code, notes, and snippets.

@madogiwa0124
Created April 11, 2017 01:49
Show Gist options
  • Save madogiwa0124/7ec088eafe62c517dcaf2177b51cfdd2 to your computer and use it in GitHub Desktop.
Save madogiwa0124/7ec088eafe62c517dcaf2177b51cfdd2 to your computer and use it in GitHub Desktop.
Twitterで話題になってた条件分岐の件を実装してみた。
hasA, hasB, hasC = true, false, true
cmd = ["foo"]
cmd << "-a AAA" if hasA
cmd << "-b BBB" if hasB
cmd << "-c CCC" if hasC
puts cmd.join(" ")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment