Scala Vector class: 170+ method examples (map, filter, fold, reduce)
Table of Contents
- Vector class introduction
- Notes about the following Vector examples
- CREATE: How to create a Vector with initial elements
- CREATE: Create a new Vector by populating it
- READ: How to access Vector elements
- UPDATE: How to add (append and prepend) elements
- UPDATE: How to “update” Vector elements using its methods
- DELETE: Filtering methods (how to “remove” elements from an Vector)
- MORE: Transformer methods
- MORE: Informational and mathematical methods
- MORE: Grouping methods
- Looping over a Vector with for and foreach
- A few things you can do with a Vector of Options
- Scala Vector summary
This page contains over 170 examples of how to use the Scala Vector class, covering most of the methods that are available on a Vector
, including map
, filter
, foldLeft
, reduceLeft
, and many more.
Scala Vector class video
As a brief update, if you prefer videos, here is my Scala Vector class training video.
The Scala Vector class
Use the Vector
class when you want to use a general-purpose, immutable indexed sequence in your Scala applications: