Here’s a question… is there a way to make a constr...
# announcements
a
Here’s a question… is there a way to make a constructor visible to it’s parent class but not to anything else?
Copy code
sealed class DString {
    class Empty internal constructor() : DString()
    class NonEmpty internal constructor(val s: String) : DString()

    companion object {
        fun create(s: String?) = if (s.isNullOrEmpty()) Empty() else NonEmpty(s!!)
    }
}
“protected” and “private” don’t work.