Raed Ghazal
02/01/2023, 2:57 PMfun foo(default: Int, a: Int = default) {
//todo
}
//good case
foo(a = 5)
foo(default = 5)
//compilation error "at least one of the attributes should be provided"
foo()
when
statement, else
is only needed if not all enum cases are addedmbonnin
02/01/2023, 3:08 PMephemient
02/01/2023, 3:25 PMRaed Ghazal
02/01/2023, 3:29 PMfun foo(default: Int, a: Int = default, b: Int = default, c: Int = default)
but following your comment, what I can do is
fun foo(a: Int, b: Int, c: Int)
fun foo(default: Int, a: Int = default, b: Int = default, c: Int = default) {
foo(a, b, c)
}
so if you don’t provide a default, you will have to use the second function and provide all the values