How to remove all occurrences of a character in a string with Scala

1 Answer

0 votes
object RemoveAllOccurrencesOfCharacterInString_Scala {
  def main(args: Array[String]): Unit = {
    val str = "Scala is a statically typed high-level general-purpose programming language"
    
    val result = str.filter(_ != 'g')
    
    println(result) // heo word
  }
}

  
  
/*
run:
  
Scala is a statically typed hih-level eneral-purpose prorammin lanuae
  
*/

 

 



answered Oct 12, 2024 by avibootz
...