abra-lang icon indicating copy to clipboard operation
abra-lang copied to clipboard

Multiline strings

Open kengorab opened this issue 4 years ago • 0 comments

Other languages make use of a delimiter to denote a string in which newlines are allowed within the string literal. Javascript uses a backtick to denote this, among other things; python uses """. I think I like the triple quotes for this:

val input = """
x,x,o
_,x,o
o,_,x
"""

Double-quote characters should be allowed within multi-line string literals unescaped.

There should also be a new method on String, trimIndentation(): String:

val input = """
  x,x,o
  _,x,o
  o,_,x
""".trimIndentation()  // produces "x,x,o\n_,x,o\no,_,x"

val code = """
  func abc() {
    return 0
  }
""".trimIndentation()  // produces "func abc() {\n  return 0\n}"

kengorab avatar Dec 18 '20 04:12 kengorab