【发布时间】:2017-05-15 15:00:42
【问题描述】:
是否可以有一个返回泛型类型的函数?比如:
fun <T> doSomething() : T {
when {
T is Boolean -> somethingThatReturnsBoolean()
T is Int -> somethingThatReturnsInt()
else -> throw Exception("Unhandled return type")
}
}
【问题讨论】: