Skip to content

Instantly share code, notes, and snippets.

@tamaki-shingo
Created January 8, 2017 14:06
Show Gist options
  • Select an option

  • Save tamaki-shingo/e61381a4841f3bae4b3d5ea4785fcfc4 to your computer and use it in GitHub Desktop.

Select an option

Save tamaki-shingo/e61381a4841f3bae4b3d5ea4785fcfc4 to your computer and use it in GitHub Desktop.
こうなった。なるほど。このほうが気持ちいいですね。もう一段階なんか方法がある気がしてたのでスッキリ。 @eduraaa #CodePiece
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