How to remove elements from Set in Scala

Welcome to Scala series. In this tutorial, you will learn about how to remove elements from Set in Scala. Scala set is a collection that stores only unique values. It doesn’t allow duplicates. Set is Iterable and inherits all functionality of the iterable interface. Check out this detailed post on Scala Set for various Set operations. Let us now understand how […]

How to add elements to Set in Scala

Welcome to Scala series. In this tutorial, you will learn about how to add elements to Set in Scala. Scala set is a collection that stores only unique values. It doesn’t allow duplicates. Set is Iterable and inherits all functionality of the iterable interface. Check out this detailed post on Scala Set for various Set operations. Let us now understand how […]

Scala Set operations explained

Welcome to Scala series. In this tutorial, you will learn about Scala Set and I have explained most of the Set operations in detail. Set is a collection to store values that don’t have/allow duplicate values. Always Set will have unique elements. Set is Iterable and inherits all functionality of the iterable interface. There are two variants of Set in Scala […]

Scala list isEmpty() operation with examples

Welcome to the Scala series. In this tutorial, you will learn about the Scala List isEmpty() operation with examples. Scala isEmpty() allows checking if the list is empty. Scala isEmpty() operation is applicable for all types of Scala collections Scala isEmpty() returns a boolean value. It returns true if the list is empty else false. isEmpty() Syntax final def isEmpty: Boolean […]

Scala list splitAt() operation with examples

Welcome to the Scala series. In this tutorial, you will learn about the Scala List splitAt() operation with examples. Scala splitAt() operation allows us to split the collection into two different collections based on the given index. splitAt() takes an index which then splits the collection into two different collections based on the index. splitAt() returns a tuple that has two […]

Scala list span() operation with examples

Welcome to the Scala series. In this tutorial, you will learn about the Scala List span() operation with examples. Scala span() operation allows us to split the collection into two different collections based on the given predicate operation.span() takes a predicate/boolean expression, prefix elements satisfying the condition will be added to one list and the element which doesn’t satisfy will be […]

Scala list groupBy() operation with examples

Welcome to the 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 list flatMap() operation with examples

Welcome to the 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> […]

Scala list map() operation with examples

Welcome to the 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 […]

Scala list contains() and containsSlice() operation with examples

Welcome to the 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 […]

Scala list apply() operation with examples

Welcome to the 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 […]

Scala list init() operation with examples

Welcome to the 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() […]

Scala list takeWhile() operation with examples

Welcome to the 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 […]