允许字符串中写变量。
插值器:
1、f,字符串格式化
val height = 1.9d
val name = “tom”
val res2 = f”$name is $height%2.2f meters tall”
2、s,字符串中插入变量值
val name = “jerray”
val res = s”hellow,$name”
val res1 = s”1+1=${1+1}”
3、raw,类似于s插值器,不对内容做转换。
val str = s”a\nb”
输出 ;
a
b
val str2 = raw”a\nb”
输出:
a\nb