且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将vararg作为数组传递给Kotlin?

更新时间:2023-11-07 21:06:22

另一种解决方案是将drive更改为fun drive(Array<out Car>) { ... }.当然,这意味着无法修改驱动器内的汽车,但避免了复制.

Another solution would be to change drive to fun drive(Array<out Car>) { ... }. This of course means that the cars inside drive cannot be modified but avoids the copying.