Created
January 8, 2017 14:06
-
-
Save tamaki-shingo/e61381a4841f3bae4b3d5ea4785fcfc4 to your computer and use it in GitHub Desktop.
こうなった。なるほど。このほうが気持ちいいですね。もう一段階なんか方法がある気がしてたのでスッキリ。 @eduraaa #CodePiece
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 UUIDRepresentable: RawRepresentable { | |
| associatedtype RawValue = String | |
| } | |
| extension UUIDRepresentable where Self.RawValue == String { | |
| func uuid() -> String { | |
| return self.rawValue | |
| } | |
| } | |
| //enum HogeInt : Int, UUIDRepresentable { //Build Error | |
| // case one = 1 | |
| // case two = 2 | |
| //} | |
| enum HogeString : String, UUIDRepresentable { | |
| case foo = "foo" | |
| case bar = "bar" | |
| } | |
| //HogeInt.one.uuid() | |
| HogeString.foo.uuid() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment