That also includes other lists and mutable lists – where you’ll get a fresh copy when calling toMutableList: And, wherever you were able to find a toList method, as discussed previously, you’ll probably also find a toMutableList. Once again, mutable lists are commonly created via the mutableListOf function, with a bunch of values as arguments. It's precisely that extra functionality that we’re interested in right now! If we consult an excerpt of a class hierarchy, we can see that MutableList specializes List, meaning everything we’ve learned about lists so far also works for their mutable counterpart, plus some extra functionality. What's so special about mutable lists? Well, you can mutate them! That, of course, doesn’t mean that these lists will turn into zombies (□♂️), but that you can change their content. But let’s put that on the back burner for a bit, and move on to a special kind of list – it's time to talk about mutable lists! Enter fullscreen mode Exit fullscreen modeĪs you may suspect, this list of list features is not quite exhaustive – as always, there’s some more to explore even on this subject.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |