1.代码如下:
fun main(args: Array<String>) {
parseType(10)
parseType("张三")
}
fun <T> parseType(thing: T) {
when (thing) {
is Int -> println("Int类型")
else -> println("其它类型")
}
}
fun main(args: Array<String>) {
parseType(10)
parseType("张三")
}
fun <T> parseType(thing: T) {
when (thing) {
is Int -> println("Int类型")
else -> println("其它类型")
}
}
本文标题:42.函数泛型
本文链接:https://www.haomeiwen.com/subject/qhyspctx.html
网友评论