HashMap的Groovy语法快捷方式(环境变量示例)

时间:2014-04-03 07:10:55

标签: groovy gradle

重写什么会更加狂野

task envvar << {
    all = System.getenv();
    for (Map.Entry<String, String> entry : all.entrySet())
    {
        System.out.println(entry.getKey() + "/" + entry.getValue());
    }
}

1 个答案:

答案 0 :(得分:7)

task envvar << {
    System.getenv().each { key, value -> println "${key}/${value}" }
}

请参阅http://groovy.codehaus.org/JN1035-Maps