view raw
αƞjiβ αƞjiβ - 8 months ago 59
Scala Question

Break out of double foreach in Scala

I have to return true or false based on field value in inner set item. My loops is as follow

myChoice.category.foreach(category => {
category.flavours.foreach(flavour=> {
if (flavour.available) true

It shoudld break and return true as soon as I have true on available but its returning false all the time. Any suggestion?


I don't have your dataset to work with, but perhaps this might do it.