-
-
Save MarcinusX/f12bf68a724d4e566f2c9aeaf4ba1978 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
// Niech x będzie nullem | |
int x; | |
// Operator ?? umożliwia użycie pewnej wartości w przypadku wystąpienia nulla | |
print(x ?? 7) //printuje 7 | |
// Dodatkowo możemy odwoływać się do zmiennych i metod za pomocą operatora ?. aby uninkąć NullPointerów | |
print(x?.toString()); //printuje null | |
// Lub dowolnie to łączyć | |
print(x?.toString() ?? 'x był nullem'); //printuje 'x był nullem' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment