Created
February 15, 2018 09:59
-
-
Save eugeniobaglieri/47dec1a20679cf4b197597de5558dcc5 to your computer and use it in GitHub Desktop.
This file contains 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
// Write some awesome Swift code, or import libraries like "Foundation", | |
// "Dispatch", or "Glibc" | |
class PFObject: Any { | |
} | |
let objsA: [PFObject] = [] | |
let objsB: [[String: Any]] = [[:]] | |
private 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") | |
} | |
} | |
public func myGenericFunc<T>(objs: [T]) { | |
return myGenericFunc(objs: objs, of: T.self) | |
} | |
myGenericFunc(objs: objsA) | |
myGenericFunc(objs: objsB) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment