Last active
March 12, 2017 01:05
-
-
Save efremidze/7c1134a013e26c15e137189eabfc32a1 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 Foundation | |
typealias Points = Int | |
extension Points { | |
func rank() -> Rank { | |
return Rank(self) | |
} | |
} | |
enum Rank { | |
case Recruit, Rookie, Pro | |
init(_ points: Points) { | |
switch points { | |
case 0..<100: | |
self = .Recruit | |
case 100..<200: | |
self = .Rookie | |
default: | |
self = .Pro | |
} | |
} | |
} | |
// demo | |
let rank = 10.rank() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment