groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David M. Karr" <davidmichaelk...@gmail.com>
Subject Required named parameters in constructor?
Date Mon, 18 Apr 2016 17:50:27 GMT
First of all, I'm not attempting a "Groovy vs. anything else" argument, 
so put away the flamethrowers.  I find myself defending Groovy when I 
have the chance.

I was, however, reading a Ruby book, as I've never looked at it before, 
as I found I had to learn about Puppet, and I concluded that you can't 
work effectively with robust Puppet modules without understanding Ruby.

As a result, I found myself paying attention to to how Ruby features map 
to Groovy.  I'm not talking about syntax, just functional features.

I got to the point in the Ruby book where it mentioned that you could 
set particular keyword parameters (like Groovy Named Parameters) to be 
required.  I can't think of a "direct" way to map this to Groovy.  I 
suppose you could implement an "ad hoc" strategy that throws if 
particular values aren't set.  Is there a more concise way?

Just as an observation, I also note that Ruby allows mixing both 
"positional" and "named" parameters in the same constructor call.

Mime
View raw message