Created
November 21, 2019 19:51
-
-
Save luizjacomn/b0b4413f35e1254d221574e77621bbcc to your computer and use it in GitHub Desktop.
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
void main() { | |
// criando variável teste. | |
String teste = 'teste'; | |
// "printa" 5 no console. | |
print(teste.length); | |
// setando valor para null. | |
teste = null; | |
// caso tente acessar a variável diretamente esta estando nula, uma exceção é lançada. | |
// com o operador ?. isso é evitado pois a variável teste somente é acessada quando seu valor for diferente de nulo. | |
print(teste?.length); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment