Last active
December 5, 2015 18:33
-
-
Save makiftutuncu/10819f466b7027146a22 to your computer and use it in GitHub Desktop.
Scala'da Temel Kavramlar yazısınındaki örnek 6
This file contains hidden or 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
def tanit(adi: String, soyadi: String, yasi: Int, erkekMi: Boolean, sadeceAdiKullan: Boolean = false): Unit = { | |
def cinsiyet(e: Boolean): String = { | |
if (e) { | |
"Erkek" | |
} else { | |
"Kadın" | |
} | |
} | |
println("Adı : " + adi) | |
if (!sadeceAdiKullan) { | |
println("Soyadı : " + soyadi) | |
println("Yaşı : " + yasi) | |
println("Cinsiyeti: " + cinsiyet(erkekMi)) | |
} | |
} | |
// Bunlar önceki örnekteki gibi çalışacak. | |
tanit("Mehmet Akif", "Tütüncü", 24, true) | |
tanit("Mehmet Akif", "Tütüncü", 24, erkekMi = true) | |
// Bunlar sadece adı yazdıracak. | |
tanit("Mehmet Akif", "Tütüncü", 24, true, true) | |
tanit("Mehmet Akif", "Tütüncü", 24, true, sadeceAdiKullan = true) | |
tanit("Mehmet Akif", "Tütüncü", 24, erkekMi = true, sadeceAdiKullan = true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment