Skip to content

Instantly share code, notes, and snippets.

@LucasArruda
Created October 31, 2012 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LucasArruda/3987136 to your computer and use it in GitHub Desktop.
Save LucasArruda/3987136 to your computer and use it in GitHub Desktop.
Can someone guess what this code does?
// ...
catMedia = (categoryId==157)?getCategoryMedia1():getCategoryMedia();
// ...
@djhonyy
Copy link

djhonyy commented Oct 31, 2012

if (categoryId == 157) {
catMedia = getCategoryMedia1(); // São métodos diferentes
} else {
catMedia = getCategoryMedia();
}

@LucasArruda
Copy link
Author

Sim, @djhonyy. Isso é uma maneira de fazer um if/else.

Mas na verdade eu estava perguntando 2 coisas.

  • O que é 157, além de uma constante mágica?
  • Qual a diferença entre um metodo blablabla() e blablabla1()?

Então, o código não esta nada legível (e não é por causa da falta do if).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment