- You can’t return explicitly from a failable context. So that stops you from using
return Y
false?
always fails, without returning any value. However, right now the compiler still wants to see the function return a value of its return type (int
) since it can’t infer that anything afterfalse?
won’t execute.
You could wrap this in an option:
Find(X:[]int, F(:int)<transacts><decides>:void)<transacts><decides>:int =
var RetInt:?int = false
for (Y:X, F[Y], not RetInt?):
set RetInt = option{Y}
RetInt?