Say I have the following enum definition:
enum SaveResult {
Saved,
Failed,
EncryptionError
}
I then have a function that returns a SaveResult
public SaveResult save() {
. . .
}
I then have a function that returns a boolean
based on the result of the save()
function:
public boolean doSomething() {
SaveResult result = this.save();
switch (result) {
case Saved:
return true;
case Failed:
return false;
case EncryptionError:
return false;
}
// Why am i still required to provide `default` case
// for the switch or a return call at the end of the
// function if all cases for the switch have already
// been covered?
//
// The error I'm getting is "Missing return statement".
}