When we created fun with Kotlin like this
fun foo(bar: Int = 0, baz: Int) { /* ... */ }
foo(baz = 1) // The default value bar = 0 is used
So in java we need to write it this way E.g.
don't need to write
void foo(int bar, int baz){
...
}
void foo(int baz){
foo(0,baz);
}
Let's imagine if we have 10+ params. I wonder how Kotlin handle this. Will Kotlin generate all possible methods? Or it just generate the method that programmer really use?
There won't be 2^N overloads generated. As said in the docs,
For a function with default parameters, say,
it will generate overloads