Scala'da Koşul İfadeleri yazımdaki örnek 2
// Java | |
String metin = "merhaba"; | |
int uzunlukSeviyesi; // 1, 2 veya 3 | |
if (metin.length < 2) { | |
uzunlukSeviyesi = 1; | |
} else if (metin.length < 4) { | |
uzunlukSeviyesi = 2; | |
} else { | |
uzunlukSeviyesi = 3; | |
} | |
// Scala | |
val metin = "merhaba" | |
val uzunlukSeviyesi = if (metin.length < 2) { | |
1 | |
} else if (metin.length < 4) { | |
2 | |
} else { | |
3 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment