Groovy method with optional parameters

前端 未结 3 1317
清酒与你
清酒与你 2021-02-01 12:43

I would like to write a wrapper method for a webservice, the service accepts 2 mandatory and 3 optional parameters.

To have a shorter example, I would like to get the f

3条回答
  •  终归单人心
    2021-02-01 13:11

    You can use arguments with default values.

    def someMethod(def mandatory,def optional=null){}
    

    if argument "optional" not exist, it turns to "null".

提交回复
热议问题