jermainedilao
08/08/2019, 7:51 AMval list = mutableListOf<String>()
variable list
will be a mutable list.
but if I have
val list: List<String> = mutableListOf<String>()
variable list
will be an immutable list.
Can someone explain the hierarchy here? Is the defined variable data type always becomes the winning data type?diesieben07
08/08/2019, 7:53 AMMutableList
and modify it.diesieben07
08/08/2019, 7:54 AMList
is simply an interface that does not allow modification of the List, but it does not mean the object is actually immutable.thana
08/08/2019, 7:54 AMMatthieu Stombellini
08/08/2019, 7:56 AMdiesieben07
08/08/2019, 7:56 AMList
is not immutablediesieben07
08/08/2019, 7:56 AMthana
08/08/2019, 7:56 AMdiesieben07
08/08/2019, 7:56 AMjermainedilao
08/08/2019, 7:57 AMjermainedilao
08/08/2019, 8:01 AMcorneil
08/08/2019, 8:42 AMlist
you can only invoke functions of List<String>