What would the return statement look like for a return signature
Either<Error, Nothing>
?
s
Sam
09/30/2024, 10:48 AM
If you're asking what goes here, the answer is... nothing 😄
Copy code
either<Error, Nothing> {
// do stuff
// what goes here?
}
The return type
Nothing
literally means that there is no possible return value. You can loop infinitely, or you can throw an exception, but you are not allowed to reach the end of the code block normally.
a
Alejandro Serrano.Mena
09/30/2024, 11:36 AM
you would need to end with either a
raise
or an exception
s
streetsofboston
09/30/2024, 12:15 PM
This type of return statement fits a polling loop quite well, that never returns (while (true) { ... }) and only throws/raises an error when something goes wrong.