Skip to content

Instantly share code, notes, and snippets.

@noncom
Created February 8, 2018 09:16
Show Gist options
  • Save noncom/921a4e322e89424c961eae54bcac41e4 to your computer and use it in GitHub Desktop.
Save noncom/921a4e322e89424c961eae54bcac41e4 to your computer and use it in GitHub Desktop.
A thought on inheritance...
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