switch
#1

Is the default in switch the same as else in 'if' ?
Example, are these two the same?
pawn Код:
case 4:
        {
            if(PlayerInfo[playerid][pNote5s] == 1)
            {
                strmid(PlayerInfo[playerid][pNote5], "None", 0, strlen("None"), 255);
                PlayerInfo[playerid][pNote5s] = 0;
                SCM(playerid, COLOR_WHITE, "Note (slot 5) has been deleted successfuly.");
            }
            else return SCM(playerid, COLOR_GREY, "**  You don't have a note at slot 5 ! ");
        }
        default: return SCM(playerid, COLOR_GREY,"You can only choose between note 1-5!");
And
pawn Код:
if(blahblah)
        {
            if(PlayerInfo[playerid][pNote5s] == 1)
            {
                strmid(PlayerInfo[playerid][pNote5], "None", 0, strlen("None"), 255);
                PlayerInfo[playerid][pNote5s] = 0;
                SCM(playerid, COLOR_WHITE, "Note (slot 5) has been deleted successfuly.");
            }
            else return SCM(playerid, COLOR_GREY, "**  You don't have a note at slot 5 ! ");
        }
        else return SCM(playerid, COLOR_GREY,"You can only choose between note 1-5!");
Reply
#2

The default: case will be called when none of the above cases match. In a way, they are comparable.
Reply
#3

yeah that's what I ment, Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)