美文网首页
groovy学习笔记-基础demo

groovy学习笔记-基础demo

作者: 流氓兔之夫 | 来源:发表于2020-06-07 21:27 被阅读0次
    /*
    println("hello groovy");
    
    def i = 8;
    println i
    
    def s = "ssss"
    println s
    
    def list = ['a', 'b']
    
    list << 'c'
    
    println list.get(2)
    
    def map = ["key1": "value1", "key2": "value2"]
    map.key3 = "value3"
    
    println map.get("key3")
    
    println "演示闭包: "
    def b1 = {
        println "hello b1"
    }
    def method1(Closure closure) {
        closure();
    }
    method1(b1)
    
    def b2 = {
        v ->
            println "hello ${v}"
    }
    def method2(Closure closure) {
        closure("lee")
    }
    method2(b2)
    
    
    def b3 = { it + 10}
    
    println b3(2)*/
    
    //List l = [1,2,3,4,5]
    //
    //println "result22 : " + l.findAll({it % 2 == 1})
    
    
    def test(int i, Closure c) {
        return c(i)
    }
    
    println test(3, {it * 2})
    
    

    相关文章

      网友评论

          本文标题:groovy学习笔记-基础demo

          本文链接:https://www.haomeiwen.com/subject/tuchtktx.html