在Kotlin中,我试图动态创建一个文件名,其中包含一个类型和一个日期,如下所示:
var filename = "ab_$type_$date.dat"
However, the second underscore in between the variables is causing a compile error:
Kotlin: Unresolved reference: name_
我知道我可以用旧的方式连接字符串:
var filename = "ab_" + type + "_$date.dat"
But I'm wondering if there is a different way to accomplish the same thing. Is there a way to escape special characters in string templates or any other way to get this to work?