Skip to content

Instantly share code, notes, and snippets.

@joshaber
Created March 11, 2015 00:56
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save joshaber/0978209efef7774393e0 to your computer and use it in GitHub Desktop.
Save joshaber/0978209efef7774393e0 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()
@joshaber
Copy link
Author

Line 18:

Execution was interrupted, reason: EXC_BAD_ACCESS

@rex-remind101
Copy link

This still an issue in Swift 2.0?

@Sega-Zero
Copy link

Checked that in swift 2.0 playground, all works as excpected

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