Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

shared library method definition with Map

I checked few jenkins shared library examples and I found that in some of them the call method define as below:

def call (Map parameters) { .... }

and in other:

def call (Map parameters = [:]) { .... }

What is the difference between definition of parameters with =[:] and without it ?

like image 770
Shurik Avatar asked Apr 18 '26 21:04

Shurik


1 Answers

Groovy supports a feature feature is called default arguments

The first example requires you to pass in a value for the parameter.

call(['key': 'value'])

The second example can be called that way, but it can also be called without specifying a value and it will use the default:

call()
like image 166
mkobit Avatar answered Apr 28 '26 08:04

mkobit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!