Multiline String Literals in Scala

package com.vff.examples
 * Extending App means I can run this class.
 * This example shows how MultilineEscaping works.
object StringLiterals extends App {

  /* This String is multiline - scala understands this from the """
   * and will look for the closing """ for the end of the String. */
  val welcomeMessage = """This is a simple
    multiline example"""


  println("---------") // separate output

  /* This version has the | sign to indicate where margins are and,
   * when combined with stripMargin, results in cleaner output. */
  val messageWithPipes = """This example
    |will have
    |cleaner output"""


This is a simple
    multiline example
This example
will have
cleaner output

One thought on “Multiline String Literals in Scala

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s