Hello - I have come across code like that in lines 7 and 8 in contrived example https://scastie.scala-lang.org/philipschwarz/OcLua2VcQDmqSN2XVpCqsA/1
_ = if <condition> throw <exception>
it seems to me they can be rewritten as in lines 14 and 15
if <condition> || (throw <exception>)
Agree?
As Jon Pretty pointed out in the thread linked by @SethTisue, “Different monad-like types might implement map
and withFilter
in ways which cause unexpected behaviour, so in the general case, there’s no equivalence guaranteed.”
In the case of List and Future the equivalence seems to hold - here is the same example but with Future rather than List: https://scastie.scala-lang.org/philipschwarz/IdXOsIR0RkOpiD7ZwPm69A/27