假设我有带换行符的字符串文字:
file :: String
file = "the first line\nthe second line\nthe third line"
有什么办法可以这样写吗?
file :: String
file = "the first line
the second line
the third line"
上面的尝试导致此错误:
factor.hs:58:33:
lexical error in string/character literal at character '\n'
Failed, modules loaded: none.
您可以像这样编写多行字符串
x = "This is some text which we escape \
\ and unescape to keep writing"
哪个打印为
"This is some text which we escape and unescape to keep writing"
如果要将此打印为两行
x = "This is some text which we escape \n\
\ and unescape to keep writing"
哪个打印为
This is some text which we escape
and unescape to keep writing
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句