1. 字符串

    1.1字符串段落

def s = """Groovy
Grails
JAVA
""" 输出结果:
Groovy
Grails
JAVA

    1.2字符串运算符操作:                                                                     

//乘法
assert "hellohello" == "hello" * 2 //减法
def st1 = "helloWorld"
def st2 = "World"
assert "hello" == st1 - st2 //截取字符串
def st1 = "helloWorld"
assert "hello" == st1[0..4]
assert "World" == st1[5..9]
assert "World" == st1[-1..-5] //从右边截取字符串

1.3数字运算

运算符名称方法
a + ba.plus(b)
a | ba.minus(b)
a * ba.multiply(b)
a / ba.div(b)
a % b取余a.mod(b)
a++后自增a.next()
a--后自减a.previous()
05-11 19:40