Created
April 28, 2019 18:53
-
-
Save cbeyls/2ce264ffe1e254243ea801267be7ff79 to your computer and use it in GitHub Desktop.
The Dog Riddle: https://zsmb.co/the-dog-riddle/
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 Animal { | |
// Cats are simple. A cat is a cat. | |
object Cat : Animal() | |
sealed class Dog : Animal() { | |
abstract val breed: String? | |
class DogWithBreed(override val breed: String) : Dog() | |
companion object : Dog() { | |
override val breed: String? | |
get() = null | |
operator fun invoke(breed: String) = DogWithBreed(breed) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment