yawkat11/16/2019, 10:22 AM
Marko Mitic11/16/2019, 10:35 AM
Kroppeb11/16/2019, 10:43 AM
doesn't work on
, but does work with
. It also works on
but IIRC on
it doesn't work because it is ambiguous. AFAIK liskov substitution principle isn't violated.
Burkhard11/16/2019, 1:10 PM
adds a, while
val mutableList += a
creates a copy. It feels like
var mutableList = mutableList + a
do 2 different things (and they do). In this special case
is not implemented as
whcih I think is what is meant by @yawkat. But as you pointed out
a = a + b
is not vallid on mutable lists that are assigned to a
so this is not really a problem.
are implemented as extension functions on
so they are called statically. This means that substitution like in liskov’s case is not an issue.
yawkat11/16/2019, 1:15 PM
Kroppeb11/16/2019, 1:15 PM
is always equivalent with
a += b
. but if both assignPlus and
a = a+b
have been defined on a, there is ambiguity.
yawkat11/16/2019, 1:16 PM
Kroppeb11/16/2019, 1:20 PM
which doesn't extend
fun hi(name:Any) = "hi" to name fun hi(name:String) = "hi, $name!"
yawkat11/16/2019, 1:34 PM
Kroppeb11/16/2019, 1:36 PM
karelpeeters11/16/2019, 5:48 PM
to mean "create a new list with an extra element".
yawkat11/16/2019, 8:14 PM