Is this an acceptable approach for removing multiple character types from a string or is there a better (more efficient way)? The "ilr".contains(_)
bit feels a little like cheating considering it will be done for each and every character, but then again, maybe this is the right way. Is there a faster or more efficient way to do this?
val sentence = "Twinkle twinkle little star, oh I wander what you are"
val words = sentence.filter(!"ilr".contains(_))
// Result: "Twnke twnke tte sta, oh I wande what you ae"