title: Groovy property iteration
body: <p>In the Groovy code below I replace the values of the <code>feck</code>, <code>arse</code>, <code>drink</code> properties of an instance of <code>Foo</code> with those of an instance of <code>Foo2</code></p>
  
  <pre><code>class Foo {
      def feck = "fe"
      def arse = "ar"
      def drink = "dr"    
  }
  
  class Foo2 {
  
      def feck = "fe2"
      def arse = "ar2"
      def drink = "dr2"
  }
  
  
  def f = new Foo()
  def f2 = new Foo2()
  
  
  ["feck", "arse", "drink"].each {it -&gt;
      f."$it" = f2."$it"
  }
  </code></pre>
  
  <p>Is there a better way to do this? My specific concern with the code above is that the property names are stored as strings in a list, which would likely be missed when (for example) using a refactoring IDE to change one of these property names.</p>