title: How can i refactor this nested if on scala
body: <p>i have this nested if in scala</p>
  
  <pre><code>   if (collection != "h" &amp;&amp; emptyColumns.contains(collection)) {
        message += s"$collection is null"
        //Id is not null
      } else if (emptyColumns.length &gt;= schemaWithoutAddedColumns.length) {
        message += s"The ID ${row.getAs(collection)} is the only valid Field"
      } else {
        message = ""
      }
  </code></pre>
  
  <p>How could i refactor it into pattern matching.</p>
  
  <p>Thanks! i'm kinda new to scala.</p>