更新时间: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.