Let me preface this by saying I am really new to Kotlin but am a little familiar with Python.
My goal is to remove all the occurrences of the characters in one string from another string via some sort of function.
I can show you how I would do this in Python :
def removechars (s, chars)
return s.translate(None, chars)
And I can use it like this :
print(removechars("The quick brown fox jumped over the sleazy dog!", "qot"))
It would give this output :
The uick brwn fx jumped ver the sleazy dg!
How can I something similar in Kotlin?
I suggest using filterNot()
in Kotlin:
"Mississippi".filterNot { c -> "is".contains(c)}
This should output "Mpp"
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With