Skip to content

Instantly share code, notes, and snippets.

@hartbit
Last active August 29, 2015 14:27
Show Gist options
  • Select an option

  • Save hartbit/cb1e986728579d04435f to your computer and use it in GitHub Desktop.

Select an option

Save hartbit/cb1e986728579d04435f to your computer and use it in GitHub Desktop.
Using self in closure to super.init
class A<T> {
init(closure: (T -> Void) -> Void) {}
}
class B<T> : A<T> {
private var lastValue: T?
override init(closure: (T -> Void) -> Void) {
super.init(closure: { sink in
closure { value in
self.lastValue = value
sink(value)
}
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment