How to add multiple elements to a Set object in Scala

Hey there!

Welcome to

In this post, we will look at a Scala program to add all Array elements to a Set object. We can use array.toSet() method or Set.apply() method to add all the elements of an Array to Set object.

Set has apply() method which accepts Repeated parameters to add multiple elements. If you are not familiar with Repeated Parameters, please go through the below article again:

Repeated Parameters in Scala

Let’s look at the program:


Happy Learning.

Please leave a reply in case of any queries.

Leave a Reply

Your email address will not be published. Required fields are marked *