Named arguments (parameters) in functions or closures

By neokrates, written on June 3, 2010

groovy   snippet

  • Join date: 11-30-99
  • Posts: 224
View Counter:
  • 11 views
Rate it
Ad
Poll
  • Best shells (or command line language) are?

    View Results

    Loading ... Loading ...
Feeds:
  • bodytext bodytext bodytext
1
2
3
4
5
6
final launchRemoteControl ( p=[p1 : 'Micro', p2:"And", p3 : "Soft" ]) {
    println p.p1 + p.p2 + p.p3
}
 
launchRemoteControl()
launchRemoteControl(p1:'Soft', p2:'', p3:'Micro')


👉 Currently, there is a limitation that if you skip one name, it will be missed in function as well (because you actually replace default map as whole)

launchRemoteControl(p1:'Soft', p3:'Micro')
Be Sociable, Share!
 
Does that help to solve your problem?
VN:F [1.8.5_1061]
Rating: 0 (from 0 votes)
0 votes 'YES'  0 votes 'NO'
TAGS
No tags for this post.
RELATED
Pages
Posts
SOCIAL
Be Sociable, Share!

Leave a Reply