samedi 7 mars 2015

Simplifying nested ifs with multiple exit points in Scala?

There has to be a better way to do this.. I'm testing for a ray-triangle intersection and my code looks something like this



if(some condition) fail
else {
...
if(some other condition) fail
else {
...
intersection
}
}


with many nested ifs. It's disgusting. I'm doing this not to use any return statements. Is there an alternate control structure I could use here to manage the various method exit points?


Aucun commentaire:

Enregistrer un commentaire