Created
November 11, 2018 09:38
-
-
Save ozcanzaferayan/d28913fb5f39a46408e6400d85e0284b to your computer and use it in GitHub Desktop.
Kotlin Nedir: null olan bir değişkene erişme
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
/* | |
* b ifadesi null olabilen bir değişken olduğu için zaten kod yazarken dahi | |
* kodun altını kırmızı ile çizerek geliştiriciyi uyarır | |
*/ | |
val l = b.length // Hata verir | |
/* | |
* Eğer gerçekten b'nin değerini yazdırmak istiyorsak sonuna ? operatörünü koyarak | |
* çalıştırmamız gerekir. | |
*/ | |
val l = b?.length // Terminal çıktısı: null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment