单行注释
单行注释以“//”开头,可以放在行的开头,也可以放在一个句子表达式的结尾。例如
// a standalone single line comment
println "hello" // a comment till the end of the line
多行注释
多汗注释以/*开头,*/结尾。。例如
/* a standalone multiline comment
spanning two lines */
println "hello" /* a multiline comment starting
at the end of a statement */
println 1 /* one */ + 2 /* two */
groovy文档类型注释
和多行注释差不多,,例如
/**
* A Class description
*/
class Person {
/** the name of the person */
String name
/**
* Creates a greeting method for a certain person.
*
* @param otherPerson the person to greet
* @return a greeting message
*/
String greet(String otherPerson) {
"Hello ${otherPerson}"
}
}
shebang 行类型注释
特殊的注释,被类UNIX系统解释执行。。例如
#!/usr/bin/env groovy
println "Hello from the shebang line"