Repeated Parameters in Scala

Hey there!

Welcome to ClearUrDoubt.com.

In this post, we will look at a program to demonstrate the Repeated Parameters in Scala.

Repeated Parameters are useful when passing variable length argument list i.e., the function is capable of accepting any number of parameters. This parameter has to be the last one in the function parameter list while declaring the function.

Lets look at a simple program:

Output:

If we would like to pass the elements of a List/Array to the function, we can update the code as below:

Output:

Happy Learning :).

Please leave a reply in case of any queries.

Leave a Reply

Your email address will not be published.