Есть ли метод Kotlin, такой как Scala's Spane, который сочетает в себе дубль и Dropwhile («Split»?)Html

Программисты Html
Anonymous
Есть ли метод Kotlin, такой как Scala's Spane, который сочетает в себе дубль и Dropwhile («Split»?)

Сообщение Anonymous »

Есть ли метод Kotlin, такой как Scala's Span, который объединяет Takehile и Dropwhile («Split»?), Но без дублированных усилий? < /p>
val foo = "111222111"
val prefix = foo.takeWhile { it == '1' } // "111"
val suffix = foo.dropWhile { it == '1' } // "222111"

// Is there a `span` method that returns both
// the matching prefix and the non-matching suffix
// with one call?
val (p, s) = foo.span { it == '1' }


Подробнее здесь: https://stackoverflow.com/questions/795 ... d-dropwhil

Вернуться в «Html»