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
var shortClosure : (Int , Int) -> Int = { | |
return $0 + $1 | |
} | |
shortClosure(5,3) // Sonuc 8 |
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
func cikarmaIslemi(sayi1:Int,sayi2:Int) -> Int { | |
return sayi1-sayi2 | |
} | |
cikarmaIslemi(sayi1:5 , sayi2:2) // sonuc 3 | |
// Şimdi aynı işi closure ile yapıyoruz | |
let closure : (Int , Int) -> Int = {(sayi1,sayi2) in | |
return sayi1-sayi2 |
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
func birSeyYap(someInt:Int) -> Int { | |
return someInt * 2 | |
} |
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
func login(_ username:String , _ password:String) -> Bool { | |
if username == "swift" && password == "1234" | |
{ | |
return true | |
}else { | |
return false | |
} | |
} |
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
func login(kullaniciAdi username:String , kullaniciSifre password:String) -> Bool { | |
if username == "swift" && password == "1234" | |
{ | |
return true | |
}else { | |
return false | |
} | |
} |
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
func tip3Fonksyion (isim : String , yas : Int) -> String { | |
return "\(isim) \(yas) yaşındadır." | |
} |
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
func parametreAlanFonksiyon (isim : String , yas : Int) { | |
print("\(isim) \(yas) yaşındadır.") | |
} |
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
func ekranaYaz() { | |
print("Swift çok eğlenceli :( ") | |
} |
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
let isimler = ["kisi1", "kisi2", "kisi3", "kisi4","kisi5"] | |
for i in isimler { | |
print("Hello, \(i)!") // Burada String interpolasyonunu görüyoruz. String içine bir değer içeren değişkenin değerini basma yolu | |
} | |
// Hello, kisi1! // burada for da ki i dir. Ve bu index isimler dizisi içinde dolaşır. Her aldığı degerden sonra for ' un içindeki | |
// kodu çalıştırır ve ekrana basar. | |
// Hello, kisi2! | |
// Hello, kisi3! | |
// Hello, kisi4! |
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
var dizi = [2,5,1,3,4] // 5 elemanlı dizi tanımlandı. | |
print(dizi.count) // dizinin eleman sayısı öğrenildi. | |
print(dizi[2]) // dizinin 2.indisinde bulunan değeri gösterdi. | |
dizi.append(7) // diziye eleman ekleme fonksiyonudur. | |
dizi.remove(at: 2) // belirtilen indexi silme fonksiyonudur. | |
print(dizi.last!) // dizinin son elemanını verir. | |
dizi.sort() // diziyi sıralamak için kullanılır | |
// Boş bir dizi belirtmek istiyorsanız şöyle yaparız |