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

document why slashy strings allow brackets but double quoted strings do not

    Details

    • Type: Documentation
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.4.5
    • Fix Version/s: 2.4.6
    • Component/s: Documentation
    • Labels:
      None

      Description

      This

      println("$()")

      gives me a compiler error "Either escape a dollar sign or bracket the value expression"

      But this

      println(/$()/)

      prints `$()` fine. No errors

      Why is there a difference? The only documented difference is that slashy strings make working with backslashes easier. I understand that a variable name cannot start with a bracket so it should be possible to make that special case. Is that the case for the slashy strings?

      Just came across this when doing something with regex.

        Attachments

          Activity

            People

            • Assignee:
              pascalschumacher Pascal Schumacher
              Reporter:
              anshbansal Aseem Bansal
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: