dimanche 12 avril 2020

If a variable belongs to a set

I would like to write the following if condition

if( (k==1)| (k==4)| (k==8) | (k== 11)| (k==12)){
       ....
} else{
       ....
}

in a more compact way, e.g. like in php where in_array checks if a value exists in an array.

Aucun commentaire:

Enregistrer un commentaire