Hey guys!
I am at the very beginning of using Kotlin and understanding certain mechanics, if I have the following:
Copy code
data class Foo(
var id: Int?,
var name: String = "bar",
var anotherVar
)
I thought I could have calls like
Foo()
or
Foo(id=1)
without needing to pass all the parameters to the constructor, am I wrong? Where can I read more about constructors in Kotlin?
e
ephemient
09/11/2021, 10:06 AM
the same applies to all callables (functions), not just constructors: all parameters must either be specified or have a default value (or both, in which case the specified value is used rather than the default)