【发布时间】:2013-12-29 15:00:22
【问题描述】:
是否可以以跨越多行的方式编写 Haskell 的“let”语句?
let a = " something in this row.
something else in this row "
否则,有没有其他方法可以创建一个跨越多行的字符串?
【问题讨论】:
是否可以以跨越多行的方式编写 Haskell 的“let”语句?
let a = " something in this row.
something else in this row "
否则,有没有其他方法可以创建一个跨越多行的字符串?
【问题讨论】:
要跨多行拆分字符串文字,请使用如下的字符串分隔符:
let a = " something in this row.\
\something else in this row\
\ and more in this row\
\ and yet more in this row "
您在要继续的每一行的末尾添加一个反斜杠,然后在文本将继续的下一行的开头添加一个反斜杠。
【讨论】:
是的。如果使用右缩进,则可以使用多行表达式。
例如,
multiLine = let a = if 1 == 2
then True else False
in a
【讨论】: