Skip to content

iosbrain/Swift-4-Generics-Playground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Swift 4 Generics Playground

This repo contains an Xcode 9 playground for exploring Swift 4 generics. Question 1: Can I write one Swift function that can find the index/position of any specific instance of any type stored in any array that stores objects of that type? Question 2: Can I write one Swift function that can determine if any specific instance of any type exists in any array that stores objects of that type? When I say "any type," I mean including custom types (like classes) that I define myself. NOTE: Yes, I know that I could use Swift Array type's built-in functions, index and contains, but I'll be using simple example code today to illustrate some points about Swift generics.