日記
冬が一番好き
今日書いたコード
struct SomeSpecialID: Equatable, ExpressibleByStringLiteral { let value: String init(stringLiteral value: String) { self.value = value } } enum Other: SomeSpecialID { case a, b, c } print(Other.a.rawValue)
感想
In particular, the raw-value type must conform to the Equatable protocol and one of the following protocols: ExpressibleByIntegerLiteral for integer literals, ExpressibleByFloatLiteral for floating-point literals, ExpressibleByStringLiteral for string literals that contain any number of characters, and ExpressibleByUnicodeScalarLiteral or ExpressibleByExtendedGraphemeClusterLiteral for string literals that contain only a single character.
https://docs.swift.org/swift-book/ReferenceManual/Declarations.html#grammar_union-style-enum-case