典型语法
new
$x
in
as
is()
Syntax
Comments
1 | // |
Keywords
as | assert | break | case |
---|---|---|---|
catch | class | const | continue |
def | default | do | else |
enum | extends | false | finally |
for | goto | if | implements |
import | in | instanceof | interface |
new | null | package | return |
super | switch | this | throw |
throws | trait | true | try |
while |
Identifiers
Strings
Groovy中有java.lang.String
和groovy.lang.GString
(字符串插值)。
1 | 'Hello' |
1 | def name = 'Ming' |
Numbers
byte
char
short
int
long
java.lang.BigInteger
float
double
java.lang.BigDecimal
Booleans
Lists
1 | def squares = [1, 4, 9] |
Arrays
1 | String[] arrStr = ['Ananas', 'Banana', 'Kiwi'] |
Maps
1 | def colors = [red: '#FF0000', green: '#00FF00', blue: '0000FF'] |
Operators
Program Structure
Object orientation
Types
1 | class Person { |
1 | extends |
Groovy支持命名参数、默认参数。
Closure
Semantics
待
2020-3-8 21:52:42