Ejemplo
if (token == “A”)
tokenNumber = 1;
else if (token == “B”)
tokenNumber = 4;
else if (token == “C”)
tokenNumber = 5;
else if (token == “X”)
tokenNumber = 10;
else
tokenNumber = 20;
if (token == “A”)
tokenNumber = 1;
else if (token == “B”)
tokenNumber = 4;
else if (token == “C”)
tokenNumber = 5;
else if (token == “X”)
tokenNumber = 10;
else
tokenNumber = 20;
Es equivalente a
tokenNumber = (token == “A”) ? 1:
(token == “B”) ? 4:
(token == “C”) ? 5:
(token == “X”) ? 10:
20;
(token == “B”) ? 4:
(token == “C”) ? 5:
(token == “X”) ? 10:
20;
Saludos
Adalberto Montanía
Comentarios
Publicar un comentario