object Command extends App{ val opts = Seq("-a AAA", "-b BBB", "-c CCC") val optFlags = Seq(true, false, true) println( "foo " + opts.zip(optFlags) .collect{case (opt, true) => opt} .mkString(" ") ) }