This file contains 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
document.getElementsByClassName(“className”) |
This file contains 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
npm install -g @angular/cli |
This file contains 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
<button onClick="satinAl()">Satın al</button> | |
<script> | |
const desteklenenOdemeYontemleri = [{ | |
supportedMethods: ['basic-card'] | |
}]; | |
const odemeDetaylari = { | |
total: { | |
label: 'Toplam', | |
amount: { |
This file contains 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
// Atama işleminin gerçekleştirilmesi ile null olmayan bir değişken üretiliyor | |
var a: String = "abc" | |
a = null // Derleme hatası verir |
This file contains 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
// ? operatör null olabilen bir değişken oluşturmayı sağlıyor | |
var b: String? = "abc" | |
b = null // Atamada bir problem yok | |
print(b) // Terminal çıktısı: null |
This file contains 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
// Üstte "abc" değerini atadığımız a değişkeni nullable olmadığı için | |
// aşağıdaki atama bir hata vermez | |
val l = a.length |
This file contains 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
/* | |
* b ifadesi null olabilen bir değişken olduğu için zaten kod yazarken dahi | |
* kodun altını kırmızı ile çizerek geliştiriciyi uyarır | |
*/ | |
val l = b.length // Hata verir | |
/* | |
* Eğer gerçekten b'nin değerini yazdırmak istiyorsak sonuna ? operatörünü koyarak | |
* çalıştırmamız gerekir. | |
*/ |
This file contains 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
fun main(args: Array<String>) { | |
val other: List = listOf('a', 'b', 'c') // Error: One type argument expected for interface List<out E> | |
} |
This file contains 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
// Aşağıdaki gibi bir array atama fonksiyonumuz olduğunu düşünelim | |
fun copy(from: Array<Any>, to: Array<Any>) { | |
assert(from.size == to.size) | |
for (i in from.indices) | |
to[i] = from[i] | |
} | |
/* | |
* main metodunda int ve Any tipinde iki array var. | |
* Any tipindeki array'e, int array'inin atanması derleme zamanı hatası verir. |
This file contains 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
class Main { | |
// Lambda fonksiyonu çağırmak için tek metod içeren Callable interface'i oluşturulur. | |
// SAM (functional interface) dediğimiz aslında bu tip interface'lerdir. | |
interface Callable<T> { T call(); } | |
public static void main(String[] args) { | |
// Callable interface'i ile bir lambda fonksiyonu oluşturulur. | |
Callable<String> strCallable = () -> "Hello world!"; | |
// call metodu ile lambda fonksiyon çağrılır | |
System.out.println(strCallable.call()); // Çıktı: Hello World |
OlderNewer