所以我有一个字符串,我想判断我是否应该一分为二,或者返回一些默认值.如下所示:
val myString = "firstPart-secondPart"
val (first, second) = when (myString.contains("-")) {
true -> myString.split('-', limit = 2)
else -> ?? <-- How would i return ("Default1", "Default2") so the destructuring still works?
}
So my question is, how do i return two default strings, so that the deconstructing works? I've used String.split()
before in order to deconstruct and it's really nice.