Last active
February 15, 2018 09:45
-
-
Save gali8/47eff051a61ccaefb00431987a28d5bd to your computer and use it in GitHub Desktop.
ConfaloGenerics
This file contains hidden or 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
//: Playground - noun: a place where people can play | |
import UIKit | |
class PFObject: Any { | |
} | |
let objsA: [PFObject] = [] | |
let objsB: [[String: Any]] = [[:]] | |
func myGenericFunc<T>(objs: [T], of type: T.Type) { | |
switch type { | |
case let x where x is PFObject.Type: | |
print("PFObject") | |
case let x where x is [String: Any].Type: | |
print("[String: Any]") | |
default: | |
print("Boh") | |
} | |
} | |
myGenericFunc(objs: objsA, of: PFObject.self) | |
myGenericFunc(objs: objsB, of: [String: Any].self) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment