Skip to content

Instantly share code, notes, and snippets.

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 miguelarauj1o/757275804a8d59f4034d2351ab0babb8 to your computer and use it in GitHub Desktop.
Save miguelarauj1o/757275804a8d59f4034d2351ab0babb8 to your computer and use it in GitHub Desktop.
import Cocoa
class GeneralThing<S> {
var stuff: S?
func doIt() {
if let s = stuff {
doWithStuff(s)
}
}
func doWithStuff(stuff: S) -> S {
return stuff
}
}
class SpecificThing<T>: GeneralThing<Int> {
override func doWithStuff(stuff: Int) -> Int {
println("\(stuff + 1)")
return stuff + 1
}
}
let t = SpecificThing<Int>()
t.stuff = 1
t.doIt()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment