Hi, I have this code: ``` class DefaultList(val ...
# announcements
Hi, I have this code:
Copy code
class DefaultList(val name: String = "", val friends: List<String>)
    class ListDefault(val friends: List<String>, val name: String = "")
    fun foo() {
        val instance = DefaultList(arrayListOf("blah"))
        val another = ListDefault(arrayListOf("blah"))
Line, where I create
variable doesn't compile. But line with creating
variable is ok. Do I really need to have a variable with default value at the end of primary constructor or is it a bug?
if your default parameters are not in the end of the list, you have to specify names. See here: https://kotlinlang.org/docs/reference/functions.html#default-arguments PS: I see it was answered and solved, but just wanted to give the ref.