Scala is a general purpose programming language designed to express common programming patterns in a concise, elegant, and type-safe way. Scala supports functional programming & is a pure object-oriented language in the sense that every value is an object. Let us discuss about some of the strongest building blocks of Scala.
Scala Lists:
Lists are an important data structure in many Scala programs. A list containing the elements x1, . . . , xn is written List(x1, …, xn).Lets have an example of List and some operations on it:
Result for the code above would look like:
With these special operations shown in this example, Lists has a lot of other convenient operations for use like below.
Result for the code above would look like:
More
Adding to the head of the list
scala> var l = List(1, 2, 3)
l: List[Int] = List(1, 2, 3)
scala> l ::= 4