Pergunta

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?

Foi útil?

Solução

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 em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top