泛型功能参考 [英] References to generic functions

查看:63
本文介绍了泛型功能参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在Kotlin中引用泛型函数?

Is it possible to make reference to generic functions in Kotlin?

例如,假设我有一个函数:

For example, let's say I have a function:

fun inline <reified T> appendToString(a: T, b: T) = a.toString() + b.toString

如何引用此功能?这将无法编译

How can you reference this function? This will not compile

var a = ::appendToString<Int>

推荐答案

当前不支持.但是,如果您希望看到它实现,则有一个功能请求可以支持:)

Currently it is not supported. But there is a feature request you can support if you would like to see it implemented :) KT-12140

这篇关于泛型功能参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆