https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
z

Zlatko

03/22/2023, 1:32 PM
tldr: as far as i understand i should be able to use kotlin.collections.jointostring inside of the shared code (android/ios), as it is part of common since kotlin 1.2 i tried to put function extension in a util file inside the shared folder in the project. function:
Copy code
fun ByteArray.toHex(): String =
        joinToString(separator = "") { eachByte -> "%02x".format(eachByte) }
which works inside the mainactivity now if i create a extension function inside the new file and import it within mainactivity
Copy code
fun <ByteArray> ByteArray.toHex(): String{
    return this.toString()
}
--
and in main activity
com.package.utils.*
it will be recognized as extended function, but i cannot get shared class to recoginz joinToString kotlin- std-lib 1.70 both android and shared(common) class are using it
r

russhwolf

03/22/2023, 1:37 PM
joinToString
is usable from common, but
format
is not. If you're having trouble resolving
joinToString
it's probably because the type inference is getting confused after it fails to resolve
format
.
z

Zlatko

03/22/2023, 1:37 PM
thank you
8 Views