I'm having trouble with the kotlin syntax for meth...
# getting-started
g
I'm having trouble with the kotlin syntax for methods that appear to have a vararg as the first parameter. I'm trying to call
line.split(": ", 2)
(line is a String). I've tried
line.split(": ", false, 2)
and
line.split(delimiters = ": ", limit = 2)
It's telling me...
After a bit more trial and error, this appears to be the correct syntax `
Copy code
val parts = line.split(": ", ignoreCase = false, limit = 2)
or
Copy code
val parts = line.split(": ", limit = 2)
It would be nice if kotlin supported some sort of syntax like this...
Copy code
val [propertyName, propertyValue] = line.split(": ", limit = 2)
e
Copy code
val (propertyName, propertyValue) = line.split(": ", limit = 2)
does work thanks to standard
operator fun component1()
etc. extensions. will throw if there's only 1 part though
g
ahh, that's interesting.. component1. Thanks @ephemient! I'll have to have a try at it.