Skip to content

Instantly share code, notes, and snippets.

@agoiabel
Created January 15, 2018 09:52
Show Gist options
  • Save agoiabel/7676f7f6b3023f304804077ecab895dc to your computer and use it in GitHub Desktop.
Save agoiabel/7676f7f6b3023f304804077ecab895dc to your computer and use it in GitHub Desktop.
enum AppleDevice {
case iPad, iPhone, AppleTv, AppleWatch
func description() -> String {
switch self {
case .iPad: return "\(self) was introduced 2006"
case .iPhone: return "\(self) was introduced 2007"
case .AppleTv: return "\(self) was introduced 2010"
case .AppleWatch: return "\(self) was introduced 2014"
}
}
}
AppleDevice.iPad.description() //will return "iPad was introduced 2006"
AppleDevice.iPhone.description() //will return "iPhone was introduced 2007"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment