Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Code Block
languagegroovy
import groovy.transform.TypeChecked
import groovy.xml.MarkupBuilder

// this method and its code are type checked
@TypeChecked
String greeting(String name) {
   generateMarkup(name.toUpperCase())
}

// this method isn't type checked
// and you can use dynamic features like the markup builder
String generateMarkup(String name) {
   def sw = new StringWriter()
   new MarkupBuilder(sw).html {
       body {
           div name
       }
   }
   sw.toString()
}

assert greeting("Cédric").contains("<div>CÉDRIC</div>CÉDRIC")

Type inference and instanceof checks

...