Kotlin - Functions
Which of the following is the correct way to declare a Kotlin function with a default parameter value?
= after the parameter type, like b: Int = 5.b: Int = 5. fun add(a: Int = 5, b: Int) { return a + b } places default before non-default parameter, which is allowed but can cause ambiguity if called without named arguments. Options A and C have invalid syntax.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions