What to do with Default Switch State?

What to do with the default switch state? everytime the editor executes a breakpoint on reaching that state.

case EItemType::E_Grenade: {
   print100s("Log Grenade Case Executed at :: line :: 394 -- Class MyGameMode");
   GrenadeClassRef->SpawnGrenade(GStaticMesh, Location);
} break;

default: {
   //What to do with this, always the engine breaks at this point or crash
} break;
   }

Hello @Alexa.Ki , should be enough using a break statement at the default state in case you don’t have any code. Also, if I’m not extremely wrong, you can omit the default in this case.

you mean just need to delete or return;?

Your switch-case should have this structure:

switch (expression)  {
    case constant1:
        // code
        break;

    case constant2:
        // code
        break;
        .
        .
        .
    default:
        break;
}
1 Like

Thank you very much I will be trying this for sure, just waiting to build the engine so I can continue debugging

If you implement every single definition for your case you do not need a default case. Technically you never do but it’s nice when you want to use it as a try/catch scenario.

1 Like