scala default parameter skip one
In Scala, default parameters can be used to specify default values for function parameters. However, Scala does not skip default parameters. When a function is called, if an argument is not provided for a parameter with a default value, the default value will be used for that parameter. Here's an example:
def greet(name: String = "John"): Unit = {
println(s"Hello, $name!")
}
greet() // Output: Hello, John!
greet("Alice") // Output: Hello, Alice!
In the above example, the greet
function has a default parameter name
with a default value of "John". When the function is called without providing an argument for name
, the default value "John" is used. When the function is called with an argument, that argument is used instead of the default value.
Please let me know if you need further assistance!