数据源 list 类型是 MutableList<OrgCode>
fun insertAll(vararg orgCode: OrgCode)
关键是使用 "spread operator",看起来就是这个: * ,这样会将参数变为Array<out OrgCode>
所以就这样写:insertAll(*list.toTypedArray())
数据源 list 类型是 MutableList<OrgCode>
fun insertAll(vararg orgCode: OrgCode)
关键是使用 "spread operator",看起来就是这个: * ,这样会将参数变为Array<out OrgCode>
所以就这样写:insertAll(*list.toTypedArray())
本文标题:kotlin语法记录:MutableList to vararg
本文链接:https://www.haomeiwen.com/subject/lmbniqtx.html
网友评论