我正在尝试使用 Scala 的 java jcommander 库。java JCommander 类有多个构造函数:
public JCommander(Object object)
public JCommander(Object object, ResourceBundle bundle, String... args)
public JCommander(Object object, String... args)
我想调用第一个不带可变参数的构造函数。我试过了:
jCommander = new JCommander(cmdLineArgs)
我得到错误:
error: ambiguous reference to overloaded definition,
both constructor JCommander in class JCommander of type (x$1: Any,x$2: <repeated...>[java.lang.String])com.beust.jcommander.JCommander
and constructor JCommander in class JCommander of type (x$1: Any)com.beust.jcommander.JCommander
match argument types (com.lasic.CommandLineArgs) and expected result type com.beust.jcommander.JCommander
jCommander = new JCommander(cmdLineArgs)
我也尝试过使用命名参数,但得到了相同的结果:
jCommander = new JCommander(`object` = cmdLineArgs)
如何告诉 Scala 我想调用不带可变参数的构造函数?
我正在使用 Scala 2.8.0。