My understanding is that in typical java/groovy, the following code would output an empty hashmap:
x = [:]
x.get("hello", "world")
print(x)
However, in Nextflow, the output is [hello:world]. Assuming this is a deliberate departure from Groovy and Java’s default behavior, are Nextflow’s modifications to the standard behavior of Java/Groovy objects documented ~comprehensively somewhere? And for this specific example, is there an elegant way to get the value stored under a key (or a default value if the key is not present) without modifying the hashmap?
This is the expected behavior in both Nextflow and Groovy. world will be returned because there is no key hello in the map. If there was one, then the value would be printed to the standard output. Check the example below:
x = ["hello":"marcel"]
x.get("hello", "world")
print(x)