3
val s = """ """Shom """

gives

:1: error: ';' expected but string literal found. val s = """ """Shom"""

Tried to escape

val s = """ ""\"Shom """

result is not as expected.

s: String = " ""\"Shom"

Shom
  • 31
  • 1

1 Answers1

3

Try with s string interpolator

val tripleQuote = """""""""  // 9 quotes in total
s"""${tripleQuote}Shom"""
res2: String = """Shom

or even inline it

s"""${"""""""""}Shom"""


s"""${List.fill(3)('"').mkString}Shom"""


s"""${"\""*3}Shom"""

which all output

"""Shom

because s String interpolators can take arbitrary expressions

s"meaning is ${41 + 1}"
// res4: String = meaning is 42
Mario Galic
  • 47,285
  • 6
  • 56
  • 98