there's no way to make a primary constructor "priv...
# getting-started
y
there's no way to make a primary constructor "private in file", right? my options for a complex initializer are objects/classes defined inside the constructed class (typically in a
companion object
), or making the file its own module and using
internal constructor
? or I guess use a secondary constructor defined as a top-level
private
function as the primary constructor, and add some sort of private primary constructor (...don't do this)
a
Another option: create a private opt-in annotation, and annotate the constructor with it.
y
oh, interesting. very Kotlin, so not something I even considered
in fact, I can think of more things this private annotation pattern "solves"
a
it's not completely water tight, because someone could still opt-in using a compiler option
y
oh. I thought the annotation itself being private prevented that