Is there a syntax for `removeThisCharacters` from ...
# random
l
Is there a syntax for
removeThisCharacters
from an entire string?
"abc".replace("a", "")
vs an idealized
"abc".remove("a")
There is
removePrefix
,
removeSuffix
and
removeSurrounding
, but not a plain
remove
😞
l
maybe write an extension function for partial application of
replace
to give you your idealised
remove
function? 🙂
l
But then I'd have to maintain it! Can I sneak it into the STDLib instead? 🙊
😁 1
k
replace("a", "")
seems to be the most concise, but also consider
filter { it != 'a' }
to avoid having to turn the char 'a' into the string "a".
e
in principle, there could be implementations of
remove('a')
that are more efficient than
filter { it != 'a' }
. in practice, JVM doesn't have them so it doesn't matter