title: Is there a way to pass default case value as an argument
body: <p>I'm trying to see if there is a way that I can incorporate the default case's value in a match expression</p>
  <pre><code>item match {
  case null =&gt; false
  case _:String =&gt; _.matches(params)
  }
  </code></pre>
  <p>I've tried looking at different options, but I couldn't really find a solution.</p>
  <p>For context this is part of this snippet of code, performing it on a <code>spark dataframe</code></p>
  <pre><code>x.filter(row =&gt; row.getAs[String](&quot;colname&quot;).matches(&quot;&quot;&quot;/regex/&quot;&quot;&quot;)).count()
  </code></pre>
  <p>but there are ocassional <code>null</code> values that make everything break.</p>
  <p>I know I can do this to get the desired result, but doesn't make sense to calculate it again</p>
  <pre><code>x.filter(row =&gt; row.getAs[String](&quot;colname&quot;) match{
           case null =&gt; false
           case _ =&gt; row.getAs[String](&quot;colname&quot;).matches(&quot;&quot;&quot;\d&quot;&quot;&quot;)
           }).count()
  </code></pre>
  <p>Any suggestions or pointers would be helpful. Thank you</p>