[导入]Groovy 学习笔记 (一)

[导入]Groovy 学习笔记 (一)
1. 关于字符串: 简单字符串可以用单引号和双引号, 但如果使用GString, 则必须使用双引号. 比如 “$foo, hello world” 多行字符串则可以使用 “”" (3个双引号), 例如: def text = “”"\ hello there ${name} how are you today? “”" 如果对这个text进行输出,会发现输出是按原样式输出的,即换行符也输出. 这在处理类似 HTML 代码时时特别有用的. 另外, 可以使用 /…/ 来定义字符串, 如: def basename = /[Strings and GString^\/]+$/ 在这种情况下, 只需对 / 进行转义: \/; 但如下定义是不合法的:def x = //, 可以这么写: def x = /${}/ 2.字符串操作: a). 字符串加减操作 def string = ‘hippopotamus’ print string - ‘hippo’ - ‘mus’ + [...]
文章来源: http://blog.baturu.com/index.php/2009/04/27/groovy_lesson_one.html

你可能感兴趣的:([导入]Groovy 学习笔记 (一))