Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Mutable vs. Immutable1:37 with andi mitre
In this video we’ll get a quick overview of the different data structures that Scala has to offer. We will take a look at the mutable and immutable collections and how to import each one.
Immutable collections -- A collection which cannot be updated or extended in place such as lists.
Mutable collections -- A collection which can be updated or extended in place instead of yielding a new collection such as arrays.
Hi, welcome to Scala Collections.
In the following videos we'll learn about collections in Scala.
Collections are a crucial part of any language and
they can range from immutable to mutable.
A mutable collection can be extended or it's contents can be updated in place.
Whereas immutable collection never changes.
Be aware that certain immutable collections may have methods to which can
update, add or remove elements but these operations will always yield
a new collection and leaves the existing collection intact.
Scala gives preference to immutable collections.
Scala collection classes can be found in scala.collection pagkage
which contains the sub packages scala.collection.immutable and
The immutable package contains collections which guarantee that the elements
will not change.
Meanwhile scala.collection.mutable provides us with operations
to change the collections in place.
For instance a raise in scala are considered mutable
because we can update the values of the array.
While list are considered immutable because we're not able to update elements
within a list.
However you'll notice that we are able to append or prepend elements to our list.
Remember in that case a new collection will be created and
the original list will remain untouched.
In the following videos we'll dive deeper into scalar collections and
begin using them in our projects.
You need to sign up for Treehouse in order to download course files.Sign up