Skip to content

Instantly share code, notes, and snippets.

@ozcanzaferayan
Created November 12, 2018 07:38
Show Gist options
  • Select an option

  • Save ozcanzaferayan/4c3c7880a0127553627e41018faa45a6 to your computer and use it in GitHub Desktop.

Select an option

Save ozcanzaferayan/4c3c7880a0127553627e41018faa45a6 to your computer and use it in GitHub Desktop.
Kotlin Nedir 2: Switch-case yapısı - çoklu durumlar
fun tekMiCiftMi(sayi: Int) : String {
return when (sayi % 2) {
0, 1 -> "Tek veya çifttir"
else -> {
throw IllegalArgumentException()
}
}
}
fun main(args: Array<String>) {
// Çıktısı: Tek veya çifttir
print(tekMiCiftMi(5))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment