tipsy
04/16/2021, 8:18 PMmyFunc(p1: String, p2: Consumer<*>, p3: String = "") {}
// is not the same as
myFunc(p1: String, p2: Consumer<*>) { myFunc(p1, p2, "") }
myFunc(p1: String, p2: Consumer<*>, p3: String) {}
the compiler does not allow you to use trailing lambdas if you use default arguments
i'm not really sure if it's an issue, but did seem odd to menanodeath
04/16/2021, 8:21 PMtipsy
04/16/2021, 8:22 PMnanodeath
04/16/2021, 8:24 PMtipsy
04/16/2021, 8:24 PMmyFunc("test") { }
nanodeath
04/16/2021, 8:25 PMtipsy
04/16/2021, 8:26 PMnanodeath
04/16/2021, 8:27 PMtipsy
04/16/2021, 8:29 PMRuckus
04/16/2021, 8:53 PMtypealias Consumer<T> = (T) -> Unit
fun myFunc(p1: String, p2: String = "", p3: Consumer<String>) {
p3(p1 + p2)
}
fun main() {
myFunc("Test") { println(it) }
myFunc("Test", "2") { println(it) }
}
Consumer<*>
as that will accept only Nothing
.)nanodeath
04/16/2021, 9:03 PMRuckus
04/16/2021, 9:06 PMMax Aller: what if you put p2 last?
david: unless i declare myFunc as two separate functions, i'm not able to call
myFunc("test") { }
nanodeath
04/16/2021, 9:17 PMtipsy
04/18/2021, 8:17 AMMax Aller: what if you put p2 last?
david: that will work
nanodeath
04/18/2021, 3:24 PMRuckus
04/18/2021, 3:32 PM