Skip to content

Instantly share code, notes, and snippets.

@ozcanzaferayan
Created November 11, 2018 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ozcanzaferayan/1383317a734ee878e7d1246ee5893689 to your computer and use it in GitHub Desktop.
Save ozcanzaferayan/1383317a734ee878e7d1246ee5893689 to your computer and use it in GitHub Desktop.
Kotlin Nedir 2: Const ve val farkı
// Ö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