Generics anlamı ve kullanımı

in #utopian-io7 years ago (edited)

Selamlar , Bu dersimizde generics konusundan bahsettim . Generics kullanımı hakkında bilgi verdikten sonra kodlama şekillerine geçeceğiz . Bundan sonra birde protocol konusu bulunmakta . Sonrasında hepsini toplu bir şekilde vereceğim . İyi seyirler , iyi dersler .

Greetings, this is the topic of generics. Once we have provided information on the use of generics, we will proceed to coding formats. Thereafter, there is a protocol topic. I will give it all in a batch afterwards. Good looking, good lessons.



Projemizin Kodları
(Project Code)



import UIKit

**// Generics ile esnek ve yeniden kullanılabilir kodlar yazılır. Bu yapılar değişken tipinden bağımsızdır.**
var sehirler = ["İstanbul","İzmir","Ankara"] // [String] Elemanları string olan bir array

var IntArray = [1,2,3] // [Int]  Elemanları int olan bir array

var DoubleArray = [3.14,2.5,3.5] // [Double]  Elemanları Double olan bir array

func iller(il:[String]){

    

    for i in il{

        print(i)

    }

}

//iller(il: sehirler)

func tamSayilar(tamSayi:[Int]){

    for ts in tamSayi{

        print(ts)

    }

}

//tamSayilar(tamSayi: IntArray)

func ondalikliSayilar(ondalikliSayi:[Double]){

    ondalikliSayi.map {print($0)}

}

//ondalikliSayilar(ondalikliSayi: DoubleArray)

**//GENERİCS TANIMLAMASI**

func herhangiBirArray<T>(array:[T]){

    array.map{print($0)}

}

//herhangiBirArray(array: sehirler)

//herhangiBirArray(array: IntArray)

//herhangiBirArray(array: DoubleArray)

**// IKI Parametreli ve Aynı TİPLİ GENERIC TANIMLAMASI**

func ikiParametreli<T>(bir:T,iki:T){

    

}

**//IKI Parametreli ve FARKLI TİPLİ GENERIC TANIMLAMASI**

func farkliTipliIkıParametreli<T,U>(bir:T, iki:U){

    

}


  • Video ya ingilizce çeviri yapana " 1 SBD " Ödül verilecektir

  • The person who makes video or english translation will be awarded "1 SBD".


Videoma ingilizce çeviri yapabilirsiniz
English subtitles can be added to the video.

Kodlara github adresimden'de ulaşabilirsiniz
You can access the code file from my "Githup" account


Önceki derslerimiz / Previous lessons.**




Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Hey @kerimcaglar I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Coin Marketplace

STEEM 0.18
TRX 0.16
JST 0.030
BTC 62561.21
ETH 2449.99
USDT 1.00
SBD 2.64