How to pass Scala array into Scala vararg method?

泄露秘密 提交于 2019-11-27 03:31:31
Yuhuan Jiang

Append :_* to the parameter in test like this

test(some:_*)

And it should work as you expect.

If you wonder what that magical :_* does, please refer to this question.

It is simple:

def test(some:String*){}

def call () {
  val some = Array("asd", "zxc")
  test(some: _*)
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!