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 | |
for (int i = 1; i <= 20; i += 2) { | |
for (j = i; j <= i * 2 && j < 14; j++) { | |
System.out.print("[" + i + ", " + j + "] "); | |
} | |
} | |
// Scala | |
for { | |
i <- 1 to 20 by 2 |
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 | |
for (int i = 1; i <= 10; i++) { | |
System.out.println(i + "!"); | |
} | |
System.out.println("Önüm, arkam, sağım, solum, sobe!"); | |
// Scala | |
for (i <- 1 to 5) println(i + "!") | |
for (j <- 6 until 11) { | |
println(j + "!") |
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 | |
int i = 1; | |
while (i <= 10) { | |
System.out.println(i + "!"); | |
i++; | |
} | |
System.out.println("Önüm, arkam, sağım, solum, sobe!"); | |
// Scala | |
var i = 1 |
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
String metin = "merhaba"; | |
int uzunlukSeviyesi = metin.length < 2 ? 1 : (metin.length < 4 ? 2 : 3); | |
switch (uzunlukSeviyesi) { | |
case 1: | |
System.out.println("Çok kısa"); | |
break; | |
case 2: | |
System.out.println("Kısa"); |
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
val metin = "merhaba" | |
val uzunlukSeviyesi = if (metin.length < 2) 1 else if (metin.length < 4) 2 else 3 | |
uzunlukSeviyesi match { | |
case 1 => println("Çok kısa") | |
case 2 => println("Kısa") | |
// Yukarıdaki hiçbir case uygun değildi, varsayılan case | |
case _ => println("Uzun") | |
} |
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 metin = "merhaba"; | |
int uzunlukSeviyesi; // 1, 2 veya 3 | |
if (metin.length < 2) { | |
uzunlukSeviyesi = 1; | |
} else if (metin.length < 4) { | |
uzunlukSeviyesi = 2; | |
} else { | |
uzunlukSeviyesi = 3; |
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
if (1 == 1 && (true || false) { | |
// Bu her zaman çalışacak | |
val mesaj = "1 == 1" | |
println(mesaj) | |
} else if (2 != 2) { | |
// Bu hiç çalışmayacak | |
println("2 != 2") | |
} else { | |
// Bu hiç da çalışmayacak | |
println("1 != 1") |
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) |
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): Unit = { | |
def cinsiyet(e: Boolean): String = { | |
if (e) { | |
"Erkek" | |
} else { | |
"Kadın" | |
} | |
} | |
println("Adı : " + adi) |
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 beni { | |
def ben {println("Bir ben vardır bende benden içeri.")} | |
println("Beni bende deme bende değilim,") | |
ben | |
} | |
beni | |
// Bu hata verecek | |
ben |