Pregunta

I'm getting stange results from triple """ quoted strings when using string interpolation and line breaks:

val foo = "bar"

s"""$foo"""

This is ok.

s"""
$foo
"""    

This is wrong, I get the following output:

"
bar
"

Why the heck are there quotation marks?

¿Fue útil?

Solución

This is just the REPL surrounding multi-line strings in quotation marks. You'll find the actual string contains no quotation marks:

res0.contains("\"")
res1 : Boolean = false
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top