Scala list groupBy() operation with examples

Welcome to Scala series. In this tutorial, you will learn about the Scala List groupBy() operation with examples. Scala groupBy() operation allows us to group the elements into a key and value pairs based on the given function.groupBy() operation will return a Map collection as the output having keys and values. Scala groupBy() operation is applicable to all types of Scala […]

Scala list flatMap() operation with examples

Welcome to Scala series. In this tutorial, you will learn about the Scala List flatMap() operation with examples. Before learning flatMap() let us understand flattening? What is flattening? Flattening helps in converting a collection of several lists or collections into a single collection. It merges all list of collections to form a single collection. Flattening = Collection<Collection <T>> to Collection<T> Examples […]

Scala list map() operation with examples

Welcome to Scala series. In this tutorial, you will learn about the Scala List map() operation with examples. Scala map() operation will transform each element of the collection to another form according to the provided function.map()  takes a function and applies the function to each element.map() returns a new collection.map() operation is mainly used to transform each element of the collection […]

Scala list contains() and containsSlice() with examples

Welcome to Scala series. In this tutorial, you will learn about the Scala List contains()  and containsSlice() operation with examples. Scala contains() Scala contains() operation allows us to check if the list has a particular element or not.contains() returns a boolean value.If the list has the given element then it returns true else false. Scala contains() operation is applicable to all […]

Scala list apply() operation with examples

Welcome to Scala series. In this tutorial, you will learn about the Scala List apply() operation with examples. Scala apply() operation allows us to take/retrieve the elements of the given index. apply() operation accepts the index and retrieves the elements of that particular index. apply() operation in Scala is similar to get() operation in Java list to retrieve the element based […]

Scala list init() operation with examples

Welcome to Scala series. In this tutorial, you will learn about the Scala List init() operation with examples. Scala init() operation allows us to take/retrieve part of the collection by eliminating the last element. init() operation will return new collection by taking all the elements but without the last element.init() will omit the last element of the collection. Scala init() operation […]

Scala list takeWhile() operation with examples

Welcome to Scala series. In this tutorial, you will learn about the Scala List takeWhile() operation with examples. Scala takeWhile() operation allows us to take the first prefix elements that satisfy the given predicate from the collection. takeWhile() operation will return new collection with prefix elements but it should satisfy the given boolean/predicate expression. Scala takeWhile() operation is applicable to all […]

Scala list takeRight() operation with examples

Welcome to Scala series. In this tutorial, you will learn about the Scala List takeRight() operation with examples. Scala takeRight() operation allows us to take the last N elements in the collection. takeRight() operation will return new collection with last/rear N elements.i.e., elements from right to left. Scala takeRight() operation is applicable to all types of Scala collections. takeRight() Syntax def […]

Scala list take() operation with examples

Welcome to Scala series. In this tutorial, you will learn about the Scala List take() operation with examples. Scala take() operation allows us to take first N elements in the collection. take() operation will return new collection with first N elements. Scala take() operation is applicable to all types of Scala collections. take() Syntax def take(n: Int): List[A] Selects the first […]

Scala List sameElements() operation with examples

Welcome to Scala series. In this tutorial, you will learn about the Scala List sameElements() operation with examples. Scala sameElements() operation is a useful operation of the Scala List or any collection which allows us to compare and check if both collections are having the same elements in the same order. When you apply sameElements() method on a collection with another […]

Scala List reverse() operation with examples

Welcome to Scala series.In this tutorial, you will learn about the Scala List reverse() operation with examples. Scala reverse() operation which allows reversing the elements of the list.reverse() operation will return a new collection by reversing the elements of the collection. reverse() operation is applicable to all types of Scala collections and it is really a useful function to work upon. […]

Scala List findLast() operation with examples

Welcome to Scala series. In this tutorial, you will learn about the Scala List findLast() operation with examples. Scala findLast() operation is a useful operation of the Scala List or any collection which allows us to get/find the last element from the list or collection based on a given predicate function. When you call this findLast() operation on a Scala list, […]

Scala List find() operation with examples

Welcome to Scala series. In this tutorial, you will learn about the Scala List find() operation with examples. Scala find() operation is a useful operation of the Scala List or any collection which allows us to get/find the first element from the list or collection based on a given predicate function. When you call this operation on a Scala list, it […]

Scala List filterNot() operation with examples

Welcome to Scala series. In this tutorial, you will learn about the Scala List filterNot() operation with examples. Scala filterNot() operation is a useful operation of the Scala List or any collection which allows us to filter elements from the list or collection which is not satisfying given predicate function. When you call this filterNot() operation on a Scala list, it […]

Scala List filter() operation with examples

Welcome to Scala series. In this tutorial, you will learn about the Scala List filter() operation with examples. Scala filter() operation is a useful operation of the Scala List or any collection which allows us to filter elements from the list or collection based on a given predicate function. When you call this operation on a Scala list, it returns a […]