Created
November 11, 2018 21:25
-
-
Save ozcanzaferayan/1383317a734ee878e7d1246ee5893689 to your computer and use it in GitHub Desktop.
Kotlin Nedir 2: Const ve val farkı
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
// Örnek basit fonksiyon | |
fun hello(): String { | |
return "Hello World" | |
} | |
/* | |
* hello fonksiyonunun geri dönüş değeri runtime'da hesaplandığı için | |
* const bir ifadeye fonksiyon geri dönüş değeri atandığında hata verir. | |
*/ | |
const val hello = hello() // Hata: Const 'val' initializer should be a constant value | |
const val hello2 = "Hello world" // Ok | |
val hello1 = hello() // Ok |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment