Skip to content

Instantly share code, notes, and snippets.

@gali8
Last active February 15, 2018 09:45
Show Gist options
  • Save gali8/47eff051a61ccaefb00431987a28d5bd to your computer and use it in GitHub Desktop.
Save gali8/47eff051a61ccaefb00431987a28d5bd to your computer and use it in GitHub Desktop.
ConfaloGenerics
//: 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