I m new to groovy, and I mread the source of a project gretty
import org.codehaus.jackson.map.ObjectMapper
class JacksonCategory {
static final ObjectMapper mapper = []
...
}
我不理解该代码<代码>。 ObjectMappermapper = [], What does [ ]
mean here? 我认为这是<条码>,但是如何将其分配给<条码>的。 ObjectMapper?
<>>>>>
取决于。 因此,这意味着:
static final ObjectMapper mapper = new ObjectMapper()
但:
String s = []
println s // -> it s `[]` not ``
而且
Integer i = []
放弃例外:
Caught: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object []
with class java.util.ArrayList to class java.lang.Integer
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object [] with class
java.util.ArrayList to class java.lang.Integer