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

GStrings and Maps

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • None
    • None
    • None
    • None

    Description

      The code

      def p = 33
      def lista = ["n${ -> p}":'a', 2:'b', 3:'c', 4:'d']
      def immutable = lista.asImmutable()
      
      println immutable
      
      println immutable["n33"]
      
      p = 44
      
      println immutable
      

      returns

      [n33:"a", 2:"b", 3:"c", 4:"d"]
      null
      [n44:"a", 2:"b", 3:"c", 4:"d"]
      null
      

      The problem is that I cannot retrieve the GString from the map.

      The very simple example:

      def m = ["n${ -> 33}":'a']
      
      println m["n33"]
      println m["n${ -> 33}"]
      println m['n${ -> 33}']
      
      println m
      

      None, returns the value of the key if the GString is composed with '$' signs.

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            ccadete ccadete
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: