美文网首页
20、map find

20、map find

作者: 许你一枝花 | 来源:发表于2023-05-10 09:27 被阅读0次
    class GroovyTest {
    
        static void main(args) {
    
            def people = [
                    1: [name:'Bob', age:32, gender:'M'],
                    2: [name:'Johnny', age:36, gender:'M'],
                    3: [name:'Claire', age:21, gender:'F'],
                    4: [name:'Amy', age:54, gender:'F']
            ]
            // 查找单个entry
            def bob = people.find{it.value.name == 'Bob'}
            println bob.key +":"+bob.value
    
        }
    }
    

    输出:

    1:[name:Bob, age:32, gender:M]
    

    相关文章

      网友评论

          本文标题:20、map find

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