title: Groovy Strings vs Java Strings
body: <p>I have a string in groovy that I make from other strings, example:</p>
  
  <pre><code>def final PREFIX = "myprefix"
  def prefix2 = PREFIX + ".whatever1"
  </code></pre>
  
  <p>Now suppose I have a <code>HashMap</code> and I want to do a lookup using <code>prefix2</code> as part of a key:</p>
  
  <pre><code>HashMap&lt;String,String&gt; map = new HashMap&lt;String,String&gt;()
  map.put("myprefix.whatever1.value","aaa")
  </code></pre>
  
  <p>If I do:</p>
  
  <pre><code>def key = "${prefix2}.value"
  String result=(map.get(key))
  </code></pre>
  
  <p>Then <code>result = null</code>, but if I do:</p>
  
  <pre><code>String key="${prefix2}.value"
  String result=(map.get(key))
  </code></pre>
  
  <p>Then <code>result = aaa</code>.</p>
  
  <p>I can understand why this happens, obviously a type inference issue. But I still find it makes me feel icky. Something just doesn't "feel right" about it. Do you know what I mean?</p>
  
  <p>Is this type of thing normal and should be "expected"? Am I asking for too much for Groovy to know that if I created the string using quotes, it should work when being used to look up a value in a <code>Hashmap &lt;String, String&gt;</code> without being defined as a <code>String</code> object reference? Is this a bug or a feature?</p>