Skip to content

Instantly share code, notes, and snippets.

@le0nidas
Created January 24, 2021 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save le0nidas/bb410f6fe230e6ac1a3b156a591dce54 to your computer and use it in GitHub Desktop.
Save le0nidas/bb410f6fe230e6ac1a3b156a591dce54 to your computer and use it in GitHub Desktop.
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