One way can be called if you have an understanding that combines Try with a predicate ( if statement):
for { x <- Try(expr) if booleanExpr } { ... }
The filter Try method can call java.util.NoSuchElementException to skip the body of the loop if booleanExpr evaluates to false .
The reason field for this exception is: "The predicate is not executed for ..."
As @Guillaume notes in the comments, the Try implementation that calls this method implements a filter - a method that the compiler calls when using a conditional (if) within for comprehension
if (p(value)) this else Failure(new NoSuchElementException("Predicate does not hold for " + value))
source share