title: How to break a for loop in spark udf
body: <p>SO I have a udf like this: </p>
  
  <pre><code>def myfunc = {udf((A:mutable.WrappedArray[mutable.WrappedArray[String]],B:mutable.WrappedArray[mutable.WrappedArray[String]]) 
  =&gt;  breakable{for(i &lt;- 0 to 2)yield( if (A(i)==B(i)) "U" //want to break here 
  else "N" //break here)})}
  </code></pre>
  
  <p>it's return me multiple U or N's, I want it to return only one letter as a final result. How do I break out the for loop?</p>