Skip to content

Instantly share code, notes, and snippets.

Created January 17, 2016 23:50
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 anonymous/44a108093e45db43b6df to your computer and use it in GitHub Desktop.
Save anonymous/44a108093e45db43b6df to your computer and use it in GitHub Desktop.
class BaseClass {
class var testProperty: String {
return "Original"
}
class func testingFunc()->Self {
return self
}
}
class ChildClass {
override class var testProperty: String {
return "Modified"
}
}
ChildClass.testingFunc().testProperty // should print "Modified"
@gonzalolarralde
Copy link

class BaseClass {
class var testProperty: String {
return "Original"
}
class func testingFunc()->BaseClass.Type {
return self
}
}

class ChildClass: BaseClass {
override class var testProperty: String {
return "Modified"
}
}

ChildClass.testingFunc().testProperty prints "Modified"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment