Make zip operation symmetrical for CharSequences (missed to generalize parameter before).
This commit is contained in:
@@ -931,14 +931,14 @@ public inline fun String.partition(predicate: (Char) -> Boolean): Pair<String, S
|
||||
/**
|
||||
* Returns a list of pairs built from characters of both char sequences with same indexes. List has length of shortest char sequence.
|
||||
*/
|
||||
public infix fun CharSequence.zip(other: String): List<Pair<Char, Char>> {
|
||||
public infix fun CharSequence.zip(other: CharSequence): List<Pair<Char, Char>> {
|
||||
return zip(other) { c1, c2 -> c1 to c2 }
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of values built from characters of both char sequences with same indexes using provided [transform]. List has length of shortest char sequence.
|
||||
*/
|
||||
public inline fun <V> CharSequence.zip(other: String, transform: (Char, Char) -> V): List<V> {
|
||||
public inline fun <V> CharSequence.zip(other: CharSequence, transform: (Char, Char) -> V): List<V> {
|
||||
val length = Math.min(this.length, other.length)
|
||||
val list = ArrayList<V>(length)
|
||||
for (i in 0..length-1) {
|
||||
@@ -947,6 +947,11 @@ public inline fun <V> CharSequence.zip(other: String, transform: (Char, Char) ->
|
||||
return list
|
||||
}
|
||||
|
||||
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||
public infix fun CharSequence.zip(other: String): List<Pair<Char, Char>> {
|
||||
return zip(other) { c1, c2 -> c1 to c2 }
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sequence from the given collection.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user