Skip to content

Instantly share code, notes, and snippets.

@markmaynard
Created June 8, 2019 14:31
Show Gist options
  • Save markmaynard/a45a2648aeb179fc10441e0233884e49 to your computer and use it in GitHub Desktop.
Save markmaynard/a45a2648aeb179fc10441e0233884e49 to your computer and use it in GitHub Desktop.
Fake Class function
inline fun <reified T: SomeThing> ThingFactory(clazz: KClass<T>): ThingFactory? =
when(clazz) {
Thing1::class -> ThingFactory(ThingFactory.ThingType.Thing1Type)
Thing2::class -> ThingFactory(ThingFactory.ThingType.Thing2Type)
else -> throw RuntimeException("Unknown type: $clazz")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment