In this lesson, you'll learn how to combine immutable lists into a new combined list.
Just to note, the original list is not modified. The
minus operator simply returns a new list, the original list maintains all of its elements as it is immutable.
Thank you Donn for your reply. Just wanted to understand one more thing, if the "minus" operator returns a new list then is it better to use MutableList instead of List?
It really depends on your use case. If you value immutability above all else, then go with immutable lists (which is usually the default for Kotlin), if you need to mutate the list and cannot do it with operators, then use a mutable list. Personally, I try to stick with immutable lists as it makes the program more predictable. No one can accidentally mutate the list and cause an unwanted side-effect that way.