Learning Kotlin: Default values
Note
- Code for the 4th Koan can be found here. * This is the 4th post in a multipart series. If you want to read more, see our series index
Previously, we covered Named Arguments, and this is a small continuation of it. We start with a simple function:
fun foo(name: String): String = todoTask3()
and we need to make it call a single Java function while providing default values—resulting in:
fun foo(name: String, number: Int = 42, toUpperCase: Boolean = false): String = JavaCode3().foo(name, number, toUpperCase)