Created
January 24, 2021 15:35
-
-
Save le0nidas/bb410f6fe230e6ac1a3b156a591dce54 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed class Name constructor( | |
val value: String | |
) { | |
object UnknownName : Name("") | |
class KnownName(value: String) : Name(value) | |
companion object { | |
fun of(value: String): Name { | |
return if (value.length in (2..25)) | |
KnownName(value) else | |
UnknownName | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment