https://kotlinlang.org logo
#announcements
Title
# announcements
p

pavi2410

06/19/2019, 8:00 PM
In the latest 1.3.40 change log, I saw
String.encodeToByteArray
experimental API introduced there. And I have been using
String.toByteArray
since always. I want to know why there is such redundancy? What's the difference between them? (I don't think there is much or any difference at all)
m

Marc Knaup

06/19/2019, 8:03 PM
String.toByteArray
is available only on the JVM and likely uses the Java standard library internally.
String.encodeToByteArray
is cross-platform and doesn't depend on Java.
👆 1
p

pavi2410

06/19/2019, 8:09 PM
Does the new function utilise the existing method on the JVM?
m

Marc Knaup

06/19/2019, 8:24 PM
p

pavi2410

06/19/2019, 8:31 PM
Many thanks to you 🙏
g

gildor

06/20/2019, 12:36 AM
Make sense, if you reuse platform implementation you do not distribute your code with stdlib, but also can reuse platform specific optimizations of JVM
2 Views