val name = "mike"
val str = """Hi, {name}!"""
println(str)
I want it output the str as Hi, mike!
, but failed. How to do this?
val name = "mike"
val str = """Hi, {name}!"""
println(str)
I want it output the str as Hi, mike!
, but failed. How to do this?
As of scala >= 2.10 string interpolations are supported:
Scala does not support string interpolation. There is a compiler plugin that implements it at http://github.com/jrudolph/scala-enhanced-strings.
Without the plugin you can use concatenation or format strings:
or of course
A total hackish solution would be to use Scala's XML interpolation:
The
text
method returns string contents of an XML construct, so our tags are stripped.