:thinking_face: Can you guess what’s the result of...
# random
o
🤔 Can you guess what’s the result of
"Hello, World".replace("","-")
?
k
I'll bait:
H-e-l-l-o-,
... you get the idea.
👍 1
e
too lazy to try, did Karel win?
k
Oh I was close, it also starts and ends with `-
:
-H-e-l-l-o- -W-o-r-l-d-!-`.
e
same with
"Hello".split("")
r
How does
"hello".split("")
produce
-H-e-l-l-o-,- -W-o-r-l-d-
? 🧌
🧌 6
e
I knew kotlin wasnt yet ready for production
e
it produces
list("", "H", "e", "l", "l", 'o", "")
r
I know, I was being facetious.
n
So an empty String in Kotlin with the split and replace functions covers every character in the String, very neat! 😄 Can see how that would come in handy with some situations.