Yeah. I would like `"Hello $name"` to compile to s...
# language-proposals
d
Yeah. I would like
"Hello $name"
to compile to something like a
StringTemplate
object (if needed, it should also still be assignable to
String
obviously). More hand-wavy API:
Copy code
interface StringTemplate {
    val placeholders: List<String>
    fun getValue(placeholder: String): Any?
    fun toString(mapper: (@ParameterName("name") String, @ParameterName("value") Any?) -> Any?): String
}
k
Tiny remark: any reason to use
@ParameterName
? Isn't there real symtax for this?
d
No there isn't afaik. But I am not sure
But I already have a better idea for the API anyways.
k
Just checked, you can give lambda parameters names:
fun foo(mapper: (name: String) -> Unit) {}
👍 1