SlideShare a Scribd company logo
Generics
Generic code enables you to write flexible, reusable functions and types that can work with any type,
subject to requirements that you define. You can write code that avoids duplication and expresses its
intent in a clear, abstracted manner.
let us: go! iOS Developers Korea
https://docs.swift.org/swift-book/LanguageGuide/Generics.html
Type Safe
Type Safe: 컴파일 시 Type Check [fail fast]
let us: go! iOS Developers Korea
Type Parameter

Type Argument
let us: go! iOS Developers Korea
Generic Function
func GenericFunction<T>( … ) -> T {
…
}
let us: go! iOS Developers Korea
Type Constraint
func GenericFunction<T>( … ) -> T where T: Protocol or Class {
…
}
let us: go! iOS Developers Korea
Generic Closure
func GenericFunction<T>(completionHandler: (T)->Void) {
…
}
let us: go! iOS Developers Korea
Protocol Associated
Types
protocol DecodingTransformType {
associatedtype Decoded
associatedtype Encoded
func transform(decoded: Decoded?) -> Encoded?
}
let us: go! iOS Developers Korea
ObjectMapper
https://github.com/tristanhimmelman/ObjectMapper
let us: go! iOS Developers Korea
NSString * value = info[@“key”] /*objc */
let value: String = info[“key”]
let value: String = info[“key”] as! String
let value: String = info[“key”] as? String ?? “”
Cannot convert value of type 'Any?' to specified type 'String'
let us: go! iOS Developers Korea
let value: String = try info.value(“key”)
value = try info.value(“key”)
let us: go! iOS Developers Korea
Live Coding
Dictionary<K, V> + Extension + Generic Function
let us: go! iOS Developers Korea

More Related Content

What's hot

Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
gautam buddha university
 
C# - Part 1
C# - Part 1C# - Part 1
C# - Part 1
Md. Mahedee Hasan
 
Framework Design Guidelines
Framework Design GuidelinesFramework Design Guidelines
Framework Design Guidelines
Mohamed Meligy
 
Whats New In C Sharp 4 And Vb 10
Whats New In C Sharp 4 And Vb 10Whats New In C Sharp 4 And Vb 10
Whats New In C Sharp 4 And Vb 10
Shravan Kumar Kasagoni
 
12pointerin c#
12pointerin c#12pointerin c#
12pointerin c#
Sireesh K
 
From Java to Kotlin
From Java to KotlinFrom Java to Kotlin
From Java to Kotlin
João Ferrão
 
Elixir Brasil 2019 - Quality: A Panacéia para seu código Elixir
Elixir Brasil 2019 - Quality:  A Panacéia para seu código ElixirElixir Brasil 2019 - Quality:  A Panacéia para seu código Elixir
Elixir Brasil 2019 - Quality: A Panacéia para seu código Elixir
Weverton Timoteo
 
Xtext: code generation
Xtext: code generationXtext: code generation
Xtext: code generation
Mikhail Barash
 
Functional programming in Android
Functional programming in AndroidFunctional programming in Android
Functional programming in Android
Max Rodriguez
 
Coding conventions
Coding conventionsCoding conventions
Coding conventions
systemcrashed
 
Understand Monad
Understand MonadUnderstand Monad
Understand Monad
Kaichao Sun
 
C++ c#
C++ c#C++ c#
C++ c#
Sireesh K
 
JetBrains MPS: Typesystem Aspect
JetBrains MPS: Typesystem AspectJetBrains MPS: Typesystem Aspect
JetBrains MPS: Typesystem Aspect
Mikhail Barash
 
Indian Language App.Development Framework for Android
Indian Language App.Development Framework for AndroidIndian Language App.Development Framework for Android
Indian Language App.Development Framework for Android
Siji Sunny
 
Testing Challenges within Agile Teams
Testing Challenges within Agile TeamsTesting Challenges within Agile Teams
Testing Challenges within Agile Teams
TechWell
 
Using kotlin for server side development
Using kotlin for server side developmentUsing kotlin for server side development
Using kotlin for server side development
선옥 장
 
Design dimensions of DSLs
Design dimensions of DSLsDesign dimensions of DSLs
Design dimensions of DSLs
Mikhail Barash
 
Python revision tour -I
Python revision tour -IPython revision tour -I
Python revision tour -I
Navodaya Vidyalaya Samiti
 
C# concepts
C# conceptsC# concepts
C# concepts
lexilijoseph
 
Tdd in practice
Tdd in practiceTdd in practice
Tdd in practice
Andrew Meredith
 

What's hot (20)

Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
C# - Part 1
C# - Part 1C# - Part 1
C# - Part 1
 
Framework Design Guidelines
Framework Design GuidelinesFramework Design Guidelines
Framework Design Guidelines
 
Whats New In C Sharp 4 And Vb 10
Whats New In C Sharp 4 And Vb 10Whats New In C Sharp 4 And Vb 10
Whats New In C Sharp 4 And Vb 10
 
12pointerin c#
12pointerin c#12pointerin c#
12pointerin c#
 
From Java to Kotlin
From Java to KotlinFrom Java to Kotlin
From Java to Kotlin
 
Elixir Brasil 2019 - Quality: A Panacéia para seu código Elixir
Elixir Brasil 2019 - Quality:  A Panacéia para seu código ElixirElixir Brasil 2019 - Quality:  A Panacéia para seu código Elixir
Elixir Brasil 2019 - Quality: A Panacéia para seu código Elixir
 
Xtext: code generation
Xtext: code generationXtext: code generation
Xtext: code generation
 
Functional programming in Android
Functional programming in AndroidFunctional programming in Android
Functional programming in Android
 
Coding conventions
Coding conventionsCoding conventions
Coding conventions
 
Understand Monad
Understand MonadUnderstand Monad
Understand Monad
 
C++ c#
C++ c#C++ c#
C++ c#
 
JetBrains MPS: Typesystem Aspect
JetBrains MPS: Typesystem AspectJetBrains MPS: Typesystem Aspect
JetBrains MPS: Typesystem Aspect
 
Indian Language App.Development Framework for Android
Indian Language App.Development Framework for AndroidIndian Language App.Development Framework for Android
Indian Language App.Development Framework for Android
 
Testing Challenges within Agile Teams
Testing Challenges within Agile TeamsTesting Challenges within Agile Teams
Testing Challenges within Agile Teams
 
Using kotlin for server side development
Using kotlin for server side developmentUsing kotlin for server side development
Using kotlin for server side development
 
Design dimensions of DSLs
Design dimensions of DSLsDesign dimensions of DSLs
Design dimensions of DSLs
 
Python revision tour -I
Python revision tour -IPython revision tour -I
Python revision tour -I
 
C# concepts
C# conceptsC# concepts
C# concepts
 
Tdd in practice
Tdd in practiceTdd in practice
Tdd in practice
 

Similar to Generics

What's coming to c# (Tel-Aviv, 2018)
What's coming to c# (Tel-Aviv, 2018)What's coming to c# (Tel-Aviv, 2018)
What's coming to c# (Tel-Aviv, 2018)
Moaid Hathot
 
over all view programming to computer
over all view programming to computer over all view programming to computer
over all view programming to computer
muniryaseen
 
Building scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thriftBuilding scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thrift
Talentica Software
 
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Maarten Balliauw
 
CORBA IDL
CORBA IDLCORBA IDL
Building scalable and language-independent Java services using Apache Thrift ...
Building scalable and language-independent Java services using Apache Thrift ...Building scalable and language-independent Java services using Apache Thrift ...
Building scalable and language-independent Java services using Apache Thrift ...
IndicThreads
 
DEF CON 23 - Saif el-sherei and etienne stalmans - fuzzing
DEF CON 23 - Saif el-sherei and etienne stalmans - fuzzingDEF CON 23 - Saif el-sherei and etienne stalmans - fuzzing
DEF CON 23 - Saif el-sherei and etienne stalmans - fuzzing
Felipe Prado
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and looping
patricia Hidalgo
 
Introduction to programming c
Introduction to programming cIntroduction to programming c
Introduction to programming c
Md. Rakibuzzaman Khan Pathan
 
FINAL.ppt
FINAL.pptFINAL.ppt
FINAL.ppt
DeveshKatiyar5
 
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
Maarten Balliauw
 
Intro To AOP
Intro To AOPIntro To AOP
Intro To AOP
elliando dias
 
Type script
Type scriptType script
Type script
srinivaskapa1
 
Event Driven Programming in C#.docx
Event Driven Programming in C#.docxEvent Driven Programming in C#.docx
Event Driven Programming in C#.docx
LenchoMamudeBaro
 
The Go Programing Language 1
The Go Programing Language 1The Go Programing Language 1
The Go Programing Language 1
İbrahim Kürce
 
C Lang notes.ppt
C Lang notes.pptC Lang notes.ppt
C Lang notes.ppt
ShivanadhuniBhanuPra
 
F# and the DLR
F# and the DLRF# and the DLR
F# and the DLR
Richard Minerich
 
Flow or Type - how to React to that?
Flow or Type - how to React to that?Flow or Type - how to React to that?
Flow or Type - how to React to that?
Krešimir Antolić
 
Android Dev Study Jam.pptx
Android Dev Study Jam.pptxAndroid Dev Study Jam.pptx
Android Dev Study Jam.pptx
AbderrahmaneSAOUDI
 
AngularConf2015
AngularConf2015AngularConf2015
AngularConf2015
Alessandro Giorgetti
 

Similar to Generics (20)

What's coming to c# (Tel-Aviv, 2018)
What's coming to c# (Tel-Aviv, 2018)What's coming to c# (Tel-Aviv, 2018)
What's coming to c# (Tel-Aviv, 2018)
 
over all view programming to computer
over all view programming to computer over all view programming to computer
over all view programming to computer
 
Building scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thriftBuilding scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thrift
 
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
 
CORBA IDL
CORBA IDLCORBA IDL
CORBA IDL
 
Building scalable and language-independent Java services using Apache Thrift ...
Building scalable and language-independent Java services using Apache Thrift ...Building scalable and language-independent Java services using Apache Thrift ...
Building scalable and language-independent Java services using Apache Thrift ...
 
DEF CON 23 - Saif el-sherei and etienne stalmans - fuzzing
DEF CON 23 - Saif el-sherei and etienne stalmans - fuzzingDEF CON 23 - Saif el-sherei and etienne stalmans - fuzzing
DEF CON 23 - Saif el-sherei and etienne stalmans - fuzzing
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and looping
 
Introduction to programming c
Introduction to programming cIntroduction to programming c
Introduction to programming c
 
FINAL.ppt
FINAL.pptFINAL.ppt
FINAL.ppt
 
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
 
Intro To AOP
Intro To AOPIntro To AOP
Intro To AOP
 
Type script
Type scriptType script
Type script
 
Event Driven Programming in C#.docx
Event Driven Programming in C#.docxEvent Driven Programming in C#.docx
Event Driven Programming in C#.docx
 
The Go Programing Language 1
The Go Programing Language 1The Go Programing Language 1
The Go Programing Language 1
 
C Lang notes.ppt
C Lang notes.pptC Lang notes.ppt
C Lang notes.ppt
 
F# and the DLR
F# and the DLRF# and the DLR
F# and the DLR
 
Flow or Type - how to React to that?
Flow or Type - how to React to that?Flow or Type - how to React to that?
Flow or Type - how to React to that?
 
Android Dev Study Jam.pptx
Android Dev Study Jam.pptxAndroid Dev Study Jam.pptx
Android Dev Study Jam.pptx
 
AngularConf2015
AngularConf2015AngularConf2015
AngularConf2015
 

Recently uploaded

WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
Postman
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Jeffrey Haguewood
 
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdfNunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
flufftailshop
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Jeffrey Haguewood
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 

Recently uploaded (20)

WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
 
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdfNunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 

Generics