title: Ternary shortcut on Groovy
body: <p>I know that the ternary operator is already a shortcut in itself, but I'm still wondering if there is a shortcut for this in <code>groovy</code>:</p>
  
  <pre><code>String typeFilter = (params?.type) ? params.type : ""
  </code></pre>
  
  <p>What I'm trying to do here is:</p>
  
  <blockquote>
    <p><em>"If the <code>HashMap</code> <code>params</code> has a <code>type</code> key, assign the value of that key to <code>typeFilter</code>, otherwise, assign <code>typeFilter</code> with an empty string"</em></p>
  </blockquote>
  
  <p>I'm thinking whether if I can avoid typing <code>params?.type</code> twice, or is this the shortest code for my given scenario? Thank you for your feedback.</p>