Far*_*deh 8 type-alias kotlin kdoc
在Kotlin v1.1 +中,可以选择声明类型别名,它为现有类型提供替代名称.这对函数类型特别有用 - 例如:
typealias OnItemClick = (view: View, position: Int) -> Boolean
Run Code Online (Sandbox Code Playgroud)
与其他成员一样,他们可以使用KDoc评论进行记录:
/**
* Type definition for an action to be preformed when a view in the list has been clicked.
*/
typealias OnItemClick = (view: View, position: Int) -> Boolean
Run Code Online (Sandbox Code Playgroud)
但是有没有一种特定的方法来记录函数类型的参数和返回类型?
Kotlin网站提供了有关记录Kotlin代码的信息,但未提及typealases.
就像函数本身一样,如果函数类型可以像这样记录下来会很好:
/**
* @param view the view that was clicked
* @param position the layout position from the ViewHolder (see
[ViewHolder.getLayoutPosition])
* @return whether the click was successful
*/
typealias OnItemClick = (view: View, position: Int) -> Boolean
Run Code Online (Sandbox Code Playgroud)
但是在KDoc中无法识别标签.
那么应该如何记录参数和返回类型?
| 归档时间: |
|
| 查看次数: |
524 次 |
| 最近记录: |