Skip to content

Instantly share code, notes, and snippets.

@chakrit
Created January 26, 2015 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chakrit/7ba69fa2b714ebb25989 to your computer and use it in GitHub Desktop.
Save chakrit/7ba69fa2b714ebb25989 to your computer and use it in GitHub Desktop.
import Foundation
class Model {
func action() {
genericPrint(self.dynamicType.self, self)
}
}
class Child: Model {
func indirect() {
action()
}
}
func genericPrint<T: Model>(type: T.Type, input: T) -> T? {
dump(NSStringFromClass(type))
dump(NSStringFromClass(T))
return input
}
Child().indirect()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment