-
-
Save miguelarauj1o/757275804a8d59f4034d2351ab0babb8 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
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