title: Replacing characters in a String in Scala
body: <p>I am trying to create a method to convert characters within a String, specifically converting all '0' to ' '. This is the code that I am using:</p>
  
  <pre><code>def removeZeros(s: String) = {
      val charArray = s.toCharArray
      charArray.map( c =&gt; if(c == '0') ' ')
      new String(charArray)
  }
  </code></pre>
  
  <p>Is there a simpler way to do it? This syntax is not valid:</p>
  
  <pre><code>def removeZeros(s: String) = 
    new String(s.toCharArray.map( c =&gt; if(c == '0') ' '))
  </code></pre>