title: Multiple assignments using with() in Groovy
body: <p>Seen good working <a href="https://stackoverflow.com/questions/24556816/groovy-multiple-assignment-with-a-map">examples</a> in groovy using <em>with</em>.</p>
  
  <p><strong>Question:</strong> However, having trouble or could not understand the reason for not giving desired output when using it with the combination of keyword <strong>this.with{..}</strong> as shown below:</p>
  
  <p>Here is the code for <strong>Person.groovy</strong></p>
  
  <pre class="lang-groovy prettyprint-override"><code>class Person {
  
      def name
      def address
      def mail
  
      Person(name, address, mail){
          this.with {
              name = name
              address = address
              mail = mail
          }
      }
  
      String toString() {
          "${name} ${address} ${mail}"
      }
  }
  </code></pre>
  
  <p>When you call the above class with below code, output is coming as <strong><code>null null null</code></strong> instead of <strong><code>abc xyz abc@example.com</code></strong></p>
  
  <pre class="lang-groovy prettyprint-override"><code>def person1 = new Person('abc', 'xyz', 'abc@example.com')
  println person1.toString()
  </code></pre>