In Kotlin, I am trying to create a file name dynamically, including type and date, for example:
var filename = "ab_$type_$date.dat"
However, the second underscore between the variables causes a compilation error:
Kotlin: Unauthorized link: name _
I know that I could concatenate strings in the old way:
var filename = "ab_" + type + "_$date.dat"
But I wonder if there is another way to do the same. Is there a way to avoid special characters in string patterns or any other way to make this work?
source
share