How do I disambiguate in Scala between methods with vararg and without

后端 未结 5 1764
无人及你
无人及你 2020-11-30 08:30

I\'m trying to use the java jcommander library from Scala. The java JCommander class has multiple constructors:

 public JCommander(Object object)  
 publi         


        
5条回答
  •  长情又很酷
    2020-11-30 09:33

    You can call the constructor with varags, but pass an empty list of varags.

    (Of course, if you know that constructing JCommander with empty varags will produce the same result as calling the overloaded constructor (or method) without vargs)

    jCommander = new JCommander(cmdLineArgs, Nil: _*)

提交回复
热议问题