Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-8564

Added support for Java like raw string literals

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 3.0.0-alpha-3
    • None
    • None
    • None

    Description

      Upcoming version of Java will include a new syntax for raw string literals using back tick character as string delimiter. For example: 

       

           String s = `Doesn't have a \n newline character in it`;
           String ss = `a multi-
               line-string`;
           String sss = ``a string with a single tick (`) character in it``;
           String ssss = `a string with two ticks (``) in it`;
           String sssss = `````a string literal with gratuitously many ticks 
      in its delimiter`````;

       

      You can read more at this thread and the official proposal page.

      The main difference compared to the Groovy multi-line string literals is that raw string literals do not require to escape special characters, such as `\`, `\n`, etc. The string is assigned to the variable exactly how is typed. This makes it very useful for Groovy based DSL. 

      Attachments

        Activity

          People

            daniel_sun Daniel Sun
            pablo72 paolo di tommaso
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: