title: The most idiomatic way to perform conditional concatenation of strings in Scala
body: <p>I'm curious what would be the best way to build a String value via sequential appending of text chunks, if some of chunks dynamically depend on external conditions. The solution should be idiomatic for Scala without much speed and memory penalties.</p>
  
  <p>For instance, how one could re-write the following Java method in Scala?</p>
  
  <pre class="lang-java prettyprint-override"><code>public String test(boolean b) {
      StringBuilder s = new StringBuilder();
      s.append("a").append(1);
      if (b) {
          s.append("b").append(2);
      }
      s.append("c").append(3);
      return s.toString();
  }
  </code></pre>