質問

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?

役に立ちましたか?

解決

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
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top