Groovy 字符串那点儿事儿
可以直接用+
assert ‘ab‘ == ‘a‘ + ‘b‘
支持多行
def aMultilineString = ‘‘‘line one line two line three‘‘‘
out:
Fri Jan 03 11:14:58 CST 2020: INFO: line one
line two
line three
如果定义多行字符串时有缩进,可以去掉,下面俩方法就行
import java.lang.Stringimport java.lang.GStringString#stripIndent() String#stripMargin()
巧合了,字符在行开头,下面两种一样
def aMultilineString1 = ‘‘‘ line one line two line three‘‘‘ def aMultilineString2 = ‘‘‘\n line one line two line three‘‘‘ log.info aMultilineString1 log.info aMultilineString2
让字符串里出现 引号 和反斜杠
下面这些是用反斜杠也能出现在字符串里
知识来源官网
http://docs.groovy-lang.org/docs/latest/html/documentation/#_shebang_line
相关推荐
软件的信雅达 2020-11-02
糖葫芦娃哈哈 2020-11-02
淡茶 2020-05-10
PHP学习笔记 2020-03-06
anvien 2020-01-08
quzhongwei 2020-01-06
tysforwork 2019-12-12
简单点好 2013-09-04
PeterHao0 2013-08-31
软件的信雅达 2019-11-19
软件的信雅达 2017-02-11
yiyilanmei 2015-04-28
无聊找点事做 2019-09-06
HaleyJenkins 2016-10-18
PeterHao0 2016-01-22
dieefer 2017-02-11
liushidexing 2016-11-03
春天花会开 2016-11-01
无聊找点事做 2015-03-28