I develop an app with Kotlin
and got this weird error today in Android Studio, so I tried the same code in InteliJ Idea as well, where I get the same behaviour. I've used the split
method so far in my Android project and it worked always like a charm.
This is the code where this behaviour appears:
val rawString = "OK;ABC;34"
val delimited = rawString.split(";",true,0).last()
So today, the compiler says that the split
method cannot be reached, because it is private in file. Go figure!
In the code above, I'm trying to get the String
"34" into my delimited
variable. Are there any restrictions that I'm missing or are there any changes made on this method?
Thanks in advance.
Use like the below, split that you have used is a private function in Strings.kt
class
val rawString = "OK;ABC;34"
val delimited = rawString.split(";", ignoreCase = true, limit = 0).last()
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