mardi 29 novembre 2016

Is omitting one of the operations in conditional ? : a good behavior? [on hold]

For instance: one way of doing conditional code is:

//set input to 100 when it is equal to 0. Do nothing when it is not valued as 0
int input = ifunction();
if(input == 0)
    input = 100;

Another way is:

input == 0 ? 100 : NULL;

It seems the second way is shorter and cleaner. How do you think? Which way is better?

Aucun commentaire:

Enregistrer un commentaire