title: Checking List of String in Groovy
body: <p>I'm new to groovy and have the following code in testing:</p>
  
  <pre><code>groovy&gt; def country_list = [] 
  groovy&gt; country_list =['sg', 'ph', 'hk'] 
  groovy&gt; for (String item : country_list) { 
  groovy&gt;     println item 
  groovy&gt;     if (country_list[item].toUpperCase() == "PH") 
  groovy&gt;         isPH = true 
  groovy&gt; } 
  groovy&gt; println isPH 
  </code></pre>
  
  <p>When run in console, it throws the exception below:</p>
  
  <pre><code>sg
  Exception thrown
  
  groovy.lang.MissingPropertyException: Exception evaluating property 'sg' for java.util.ArrayList, Reason: groovy.lang.MissingPropertyException: No such property: sg for class: java.lang.String
  at ConsoleScript6.run(ConsoleScript6:5)
  </code></pre>
  
  <p>What does the error mean ?</p>
  
  <p>I do resolve the issue by this :</p>
  
  <pre><code>isPH = ('PH' in country_list) || ('ph' in country_list)
  </code></pre>
  
  <p>But really want to understand the error above.
  Thanks,
  Paul</p>