Skip to content
StefanosChaliasos edited this page Feb 5, 2021 · 3 revisions

Variance

  • Use-site variance

Type Inference

https://docs.groovy-lang.org/latest/html/documentation/core-semantics.html#type-inference

Variables

It is worth noting that although the compiler performs type inference on local variables, it does not perform any kind of type inference on fields, always falling back to the declared type of a field.

  • Local Variables: Y
  • Fields: X

Smart Cast

void doSomething(def o) {
    if (o instanceof Greeter) {     
        println o.greeting()        
    }
}
Clone this wiki locally