You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 16, 2018. It is now read-only.
We can't add this to the style guide because I don't think we can make it a hard rule. But it's a good candidate for a hopefully forthcoming best practices / patterns section.
One notable exception is lambdas. Lambdas are a higher priority for being last in the parameter list. fun foo(unused: Any? = null, a: (String) -> Unit) {} foo {} works here without needing to name the a parameter. That is, no need for foo(a = {}).
https://android.github.io/kotlin-guides/interop.html#function-overloads-for-defaults
mentions this but in a different context.
This is useful even in pure Kotlin, regardless of Java interop because it doesn't require naming the other parameters at the call site.
data class Pizza(val cheese: Boolean, val toppings: List<String> = listOf())
Pizza(true)
instead of
data class Pizza(val toppings: List<String> = listOf(), val cheese: Boolean)
Pizza(cheese = true)
The text was updated successfully, but these errors were encountered: