def x = [ "a", "qrs" ] as String
myMap.class return null?
In Groovy, maps override the dot operator to behave the same as the index[ ] operator. So
myMap.size is the same as calling
Use this instead:
myMap.size(). See the User Guide.
Why is my map returning null values?
Chances are, you tried to use a variable as a key in a map literal definition.
Remember, keys are interpreted as literal strings:
myMap = [myVar:"one"]; assert myMap["myVar"] == "one"
Try this (note the parentheses around the key):
myMap = [(myVar):"one"]