Created
December 15, 2015 21:13
-
-
Save makiftutuncu/75a33a9338df0126bbdd to your computer and use it in GitHub Desktop.
Scala'da Döngü İfadeleri Yazımdaki Örnek 4
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
// Java | |
String[] isimler = new String[] {"Ali", "Veli", "Ahmet", "Hüseyin", "Akif"}; | |
String[] secilenIsimler = new String[isimler.length]; | |
int i = 0; | |
for (String isim : isimler) { | |
if (isim.startsWith("A") && isim.length > 3) { | |
System.out.println("Seçilen isim: " + isim); | |
secilenİsimler[i] = isim; | |
i++; | |
} | |
} | |
// Scala | |
val isimler: Array[String] = Array("Ali", "Veli", "Ahmet", "Hüseyin", "Akif") | |
val secilenIsimler: Array[String] = for (isim <- isimler if isim.startsWith("A") && isim.length > 3) yield { | |
println("Seçilen isim: " + isim) | |
isim | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment