Reputation: 1734
I know that I can do string interpolation with s""
, but how can I insert double quotes inside of s""
?
scala> val x = "x"
x: String = x
scala> s""
res5: String = ""
scala> s"${x}"
res6: String = x
scala> s"${x}\""
<console>:1: error: unclosed string literal
s"${x}\""
Upvotes: 2
Views: 4307
Reputation: 7928
You just need to surround your String with triple-double quotes:
scala> s"""${x}""""
res1: String = 5"
Upvotes: 8