سؤال

Is it possible to write Haskell's "let" statement in a way that it spans multiple rows ?

let a = " something in this row.


          something else in this row "

Or else , is there any other way to create a string which spans multiple rows ?

هل كانت مفيدة؟

المحلول

To break up a string literal across multiple lines, use a string break like this:

let a = " something in this row.\
          \something else in this row\
          \ and more in this row\
          \ and yet more in this row "

You put a backslash at the end of each line you want to continue, and then another one at the start of the next line where the text will continue from.

نصائح أخرى

Yes. You can use multiple row expression if you use right indention.

For example,

multiLine = let a = if 1 == 2
                       then True else False
                 in a
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top