1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| class View<T>(val clazz: Class<T>) { val presenter by lazy { clazz.newInstance() }
companion object { inline operator fun <reified T> invoke() = View(T::class.java) } }
class Presenter { override fun toString(): String { return "presenter" } }
fun main(args: Array<String>) { val a = View.invoke<Presenter>().presenter println(a) val b = View<Presenter>().presenter println(b) }
|