groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Edinson E. PadrĂ³n Urdaneta <edinson.padron.urdan...@gmail.com>
Subject [Question] Variable Argument Lists, Named Arguments, Optional Parameters and Multiple assignment
Date Fri, 14 Aug 2015 17:10:10 GMT
Greetings, everyone,

I have a couple of questions I would like to address with you (if possible)
and the best way to explain them (potentially) is through the following
lines of code

    def foo(Map kwargs, Object bar) { /*...*/ }                     //
Instead of this ...
    def foo(Object bar, Map kwargs) { /*...*/ }                     // ...
wouldn't this be more clear ...
    def foo(Object bar, Object[] args) { /*...*/ }                  // ...
just like this one? ...
    def foo(Object bar, Object[] args, Map kwargs) { /*...*/ }      // ...
and we could combine both this way

    def foo(Object a=null, Object b) { /*...*/ }                    //
Shouldn't it rise an error?

    def (int a, int b, int[] rest) = [1, 2, 3, 4]                   //
Given this ...
    assert a == 1 && b == 2 && rest == [3, 4]                       // ...
why something like this doesn't hold?


Gist mirror ~> https://gist.github.com/EPadronU/c1d2455b67b400905530

Thanks in advance for your time

Mime
View raw message