Skip to content

Instantly share code, notes, and snippets.

@robfletcher
Last active March 4, 2016 02:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robfletcher/d9207087ca9665bfa0da to your computer and use it in GitHub Desktop.
Save robfletcher/d9207087ca9665bfa0da to your computer and use it in GitHub Desktop.
import groovy.transform.*
@CompileStatic
Map<String, ?> makeMap() {
def map = [string: "string"]
map.number = 1
return map
}
def map = makeMap()
map.each { println it.value.getClass().name }
@dmahapatro
Copy link

This is weird. I have also noticed it works for initialization like below:

def map = [string: 'string', numbers: [1, 2, 3, 4].collect { [n: it] } ]

@dmahapatro
Copy link

println map.number.getClass().name

immediately after line 6 prints as String.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment