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.
iosbrain / swift-4-generics-playground Goto Github PK
View Code? Open in Web Editor NEWAn Xcode 9 playground for exploring Swift 4 generics.
Home Page: http://iosbrain.com/blog/2018/01/02/understanding-swift-4-generics-and-applying-them-to-your-code/
License: MIT License