美文网首页
21、map putAll

21、map putAll

作者: 许你一枝花 | 来源:发表于2023-05-11 09:27 被阅读0次
class GroovyTest {

    static void main(args) {
        def defaults = [1: 'a', 2: 'b', 3: 'c', 4: 'd']
        def overrides = [1: 'z', 5: 'x', 13: 'x']

        defaults.putAll(overrides)
        print defaults
    }

输出:

[1:z, 2:b, 3:c, 4:d, 5:x, 13:x]

相关文章

网友评论

      本文标题:21、map putAll

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