Created
April 21, 2016 05:53
-
-
Save rayfix/11f2b2c9adc1b7dbe87a7324ac704ac6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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() |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This example is contrived. It makes much more sense to just implement Actionable at the point it is declared.