benleggiero
03/25/2017, 2:55 AMfun String.differingCharacters(other: String): List<Char> {
var endList: MutableList<Char> = mutableListOf()
(0..min(this.length, other.length)).forEach { index ->
val thisChar = this[index]
val otherChar = other[index]
if (thisChar != otherChar) {
endList += thisChar
}
}
if (this.length < other.length) {
endList += other.substring(this.length).toCharArray().asList()
} else if (other.length > this.length) {
endList += other.substring(this.length).toCharArray().asList()
}
return endList
}
Errors:
Error:(123, 21) Kotlin: Assignment operators ambiguity:
public operator fun <T> Collection<Char>.plus(element: Char): List<Char> defined in kotlin.collections
@InlineOnly public operator inline fun <T> MutableCollection<in Char>.plusAssign(element: Char): Unit defined in kotlin.collections
Error:(127, 17) Kotlin: Assignment operators ambiguity:
public operator fun <T> Collection<Char>.plus(elements: Iterable<Char>): List<Char> defined in kotlin.collections
@InlineOnly public operator inline fun <T> MutableCollection<in Char>.plusAssign(elements: Iterable<Char>): Unit defined in kotlin.collections
Error:(129, 17) Kotlin: Assignment operators ambiguity:
public operator fun <T> Collection<Char>.plus(elements: Iterable<Char>): List<Char> defined in kotlin.collections
@InlineOnly public operator inline fun <T> MutableCollection<in Char>.plusAssign(elements: Iterable<Char>): Unit defined in kotlin.collections
ilya.gorbunov
03/25/2017, 4:58 AM+=
operator on var MutableList can be interpreted either as list.plusAssign(char)
or as list = list.plus(char)
, therefore it's an ambiguityilya.gorbunov
03/25/2017, 4:59 AMbenleggiero
03/25/2017, 5:38 PMplusAssign
wasn't there what would happen?