Hi, I have this code: ``` class DefaultList(val ...
# announcements
d
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
instance
variable doesn't compile. But line with creating
another
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?
c
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.