Created
December 4, 2016 04:15
-
-
Save kateinoigakukun/1b5c12d4a0e2681f2dceb3299a3351d0 to your computer and use it in GitHub Desktop.
そういえばEnumにProtocolExtensionするの一応できました。 #CodePiece
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
protocol EnumStringConvertible {} | |
extension EnumStringConvertible where Self: Hashable { | |
var string: String { | |
return String(describing: self) | |
} | |
} | |
enum Hoge: EnumStringconvertible { | |
case yo | |
} | |
Hoge.yo.string //"yo" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment