Named and Default parameters in Scala

Hey there!

Welcome to ClearUrDoubt.com.

In this post, we will look at a program to demonstrate the Named and Default parameters in Scala.

Named Parameters: When a function is defined, we have to pass the parameters in the same order as defined in the function definition. Named parameters will let us pass the parameters in any order.

Default Parameters: Scala provides a way to pass default values to the parameters while defining the function. If the default value is provided, the function will not complain if we don’t pass the parameter while calling the function.

Let’s look at a simple program:

Output:

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 *