Unify an "IF statement"

Hi I would like to simplify this IF list into a single one

if (Level == minvalue -1) {Level = minvalue;}
if (Level == minvalue -2) {Level = minvalue;}
if (Level == minvalue -3) {Level = minvalue;}

I had tried this but it doesn't work
if (Level == minvalue -1 -2 -3) {Level = minvalue;}

Thanks.

if (Level <= -1 && Level >= -3)

are you just trying to make sure Level is no less than some min value?

    if (Level < minvalue)
        Level = minvalue);

Hi yes, I have to make a correction in a range of only 3 points

if (Level == minimum value -1) {Level = minimum value;}
if (Level == minimum value -2) {Level = minimum value;}
if (Level == minimum value -3) {Level = minimum value;}

as I did it works perfectly but I wanted to optimize the code maybe unifying in a single IF.

if (Level == minvalue -1 || Level == minvalue -2 || Level == minvalue -3) { 
    Level = minvalue;
}
1 Like

Thanks exactly what I was looking for

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.