Last active
December 20, 2015 16:19
-
-
Save marciojrtorres/6160932 to your computer and use it in GitHub Desktop.
Estendendo a API da linguagem com métodos utilitários
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// em inglês: | |
class StringUtilities { | |
boolean isNumber(String string) { | |
// ... | |
} | |
} | |
// situação de uso em que parece parte da linguagem: | |
if (StringUtilities.isNumber(var)) { | |
// ... | |
} | |
// em português: | |
class UtilitarioString { | |
boolean ehNumero(String string) { | |
// ... | |
} | |
} | |
// situação de uso em que parece algo feito para o momento: | |
if (UtilitarioString.ehNumero(var)) { | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment