It's pretty clear, from the scala docs, that you can use string interpolation:
val name = "James"
println(s"Hello, $name") // Hello, James
But, is it also possible to do this, where the format e.g. "Hello, $name" is in a variable?
I've tried something like this:
val name = "James"
val fmt = "Hello, $name"
println(s fmt)
println(s(fmt))
But, so far, nothing works. Is it even possible?
sresolves to a function scala-lang.org/api/current/scala/StringContext.html