This file contains hidden or 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
$a = 1; | |
$b = "a"; | |
$c = $a + $b; // conversão implícita, "a" é avaliado como 0 | |
print $c; // imprime 1 |
This file contains hidden or 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
// Os códigos aparecem nestes quadros, com fonte de largura fixa e destaque da sintaxe | |
public class Ola { | |
private final String quem; | |
public Ola(String quem) { | |
this.quem = quem; | |
} | |
@Override |
This file contains hidden or 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
function soma(a, b) { | |
return a + b; | |
} | |
document.write(soma(2, 3)); // ok, imprime 5 | |
document.write(soma(2, "3")); // o que será impresso, 23 ou 5? |
This file contains hidden or 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
function soma($a, $b) { | |
return $a + $b; | |
} | |
// imprime 5, o PHP converte o 3 de string para inteiro | |
print(soma(2, "3")); | |
print(soma("12/01/2012", "30")); // o que será impresso? |
This file contains hidden or 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
def soma(a, b) | |
return a + b | |
end | |
soma("q", "w") # ok, imprime qw, o método "q".+("w") faz a concatenação | |
soma(2, 3) # ok, imprime 5, o método 2.+(3) faz a soma | |
soma("q", 3) # falha, não é possível somar string/número sem conversão | |
# explícita: | |
TypeError: can't convert Fixnum into String | |
from (irb):2:in `+' |
This file contains hidden or 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
public class CreditoService { | |
public ? checaCredito(String documento) { | |
// ... | |
// ws.checaCPF(documento); | |
// ws.checaRG(documento); | |
return ?; | |
} | |
} |
This file contains hidden or 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
// as classes em negrito não existem ainda | |
public class CreditoService { | |
public CreditoCheck checaCredito(TipoDocumento tipo, String documento) { | |
CreditoCheck creditoCheck = null; | |
if (tipo == TipoDocumento.CPF) { | |
creditoCheck = CreditoCheck.fromDivida(ws.checaCPF(documento)); | |
} else if (tipo == TipoDocumento.RG) { | |
creditoCheck = CreditoCheck.fromDivida(ws.checaRG(documento)); | |
} | |
return creditoCheck; |
This file contains hidden or 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
class CreditoCheck { | |
boolean temDivida() { | |
return valorDivida > 0.0; | |
} | |
// ... |
This file contains hidden or 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
public class Main { | |
public static void main(String[] args) { | |
VencimentoUtil venc = new VencimentoUtil(); | |
System.out.println("hoje: " + new Date().toLocaleString()); | |
System.out.println("venc: " + | |
venc.proximoVencimento().toLocaleString()); | |
// ... |
This file contains hidden or 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
public static void armazena(String texto) throws Exception { | |
FileWriter fw = new FileWriter("/tmp/app-temp.txt", true); | |
fw.write(s); | |
fw.flush(); | |
fw.close(); | |
} | |
public static String recupera() throws Exception { | |
BufferedReader br = new BufferedReader(new FileReader("/tmp/app-temp.txt")); | |
String linha = null; |