![]() ![]() To continue using delegation (if you must), you can make the primary constructor private and move this internal constructor to be a secondary one.Īlso, why a data class? It's going to have the wrong semantics. I think you'd be better off just having a regular constructor with that signature, but actually storing listOf(head) + tail as a private member. ) : NonEmpt圜ollection, List by listOf(head) as Collection + tailĭoesn't this mean your NonEmptyList is actually holding three references instead of two (the delegate list gets held as well)? That's purely redundant, if I'm correct. These types are not zero-cost, either, of course, but it's better than nothing.Īlthough, the implementation seems weird to me: data class NonEmptyList internal constructor( The number one annoying thing in most languages, for me, is that there is no zero-cost type for NonEmptyList and NonEmptyString. ![]() An empty String may as well be null- the fact that I have to explicitly account for empty is super frustrating. 99.9% of the time, if I say I want a String, I actually want a NonEmptyString. Even more than that would be a NonEmptyString type. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |