【发布时间】:2015-10-28 00:23:52
【问题描述】:
我有一个方法如下:
void display(def a = null, def b = null) {
// user provides either value for a, or b
// if he gives value for a, it will be used
// if he gives value for b, it will be used
// not supposed to provide values for both a and b
}
我的问题是,用户应该如何为 b 提供价值?
如果我使用
display(b = 20)
它将 20 分配给 a,这是我不想要的。
完成此操作的唯一方法是按如下方式调用吗?
display(null, 20)
【问题讨论】:
标签: groovy