Groovy web console

subscribe to the feed Subscribe
to this
site

aa

Published 2 months ago by bbb with tags a
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def a = [args: ["a1", "a2"], sonarqube: [enabled: "true", quality: ["q1", "q1"]]]

def b = [sonarqube: [enabled: "false"]]


def merge(Map[] sources) {
  if (sources.length == 0) return [:]
  if (sources.length == 1) return sources[0]

  sources.inject([:]) { result, source ->
    source.each { k, v ->
      result[k] = result[k] instanceof Map ? merge(result[k], v) : v
    }
    result
  }
}

print(merge(a, b))