You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the section Introduction under subsection Variables it would be very helpful if you showed an example where read-only variable refers to mutable object such as list with an explanation that variable itself is immutable, but object it refers to is mutable.
Because later in the subsection Generics there is this code:
class MutableStack<E>(vararg items: E) {
private val elements = items.toMutableList()
fun push(element: E) = elements.add(element)
...
}
This part was very unclear to me, it didn't quite get how can you add items to variable elements if the variable is immutable. Until I read at this source the following:
Also, while the read-only variable may not be reassigned while it is in scope, it can still refer to an object which is in itself mutable (such as a list).
That's why I think it would be very useful if you added explanation about immutable variables referring to mutable objects in the section Variables.
The text was updated successfully, but these errors were encountered:
In the section Introduction under subsection Variables it would be very helpful if you showed an example where read-only variable refers to mutable object such as list with an explanation that variable itself is immutable, but object it refers to is mutable.
Because later in the subsection Generics there is this code:
This part was very unclear to me, it didn't quite get how can you add items to variable
elements
if the variable is immutable. Until I read at this source the following:That's why I think it would be very useful if you added explanation about immutable variables referring to mutable objects in the section Variables.
The text was updated successfully, but these errors were encountered: