Skip to content

Instantly share code, notes, and snippets.

@rayfix
Created April 21, 2016 05:53
Show Gist options
  • Select an option

  • Save rayfix/11f2b2c9adc1b7dbe87a7324ac704ac6 to your computer and use it in GitHub Desktop.

Select an option

Save rayfix/11f2b2c9adc1b7dbe87a7324ac704ac6 to your computer and use it in GitHub Desktop.
protocol Actionable {
func action()
}
enum Planets: Actionable {
case Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune
}
protocol PlanetsKind {}
extension Planets: PlanetsKind {}
extension Actionable where Self: PlanetsKind {
func action() {
print ("Planets!")
}
}
let m = Planets.Mercury
m.action()
@rayfix

rayfix commented Apr 21, 2016

Copy link
Copy Markdown
Author

This example is contrived. It makes much more sense to just implement Actionable at the point it is declared.

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