Created
February 8, 2018 09:16
-
-
Save noncom/921a4e322e89424c961eae54bcac41e4 to your computer and use it in GitHub Desktop.
A thought on inheritance...
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
interface Data<T: Data> { | |
companion object { | |
abstract fun decode(encoded: Encoded): T | |
} | |
} | |
class Coords2D : Data<Coords2D> { | |
companion object { | |
fun decode(encoded: Encoded): Coords2D { | |
... | |
} | |
} | |
} | |
class Coords3D : Data<Coords3D> { | |
companion object { | |
fun decode(encoded: Encoded): Coords3D { | |
... | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment