Skip to content

Is it possible to get the enum case values/payloads? #108

@blacktop

Description

@blacktop
enum MyEnum: String {
    case A = "test"
    case B
    case C
}

struct Name {
    var a: MyEnum
    var b: MyEnum
}

Name(a: .A, b: .B)
let info = try! typeInfo(of: MyEnum.self)
print(info)

TypeInfo(kind: Runtime.Kind.enum, name: "MyEnum", type: SwiftDump.MyEnum, mangledName: "MyEnum", properties: [], inheritance: [], size: 1, alignment: 1, stride: 1, cases: [Runtime.Case(name: "A", payloadType: nil), Runtime.Case(name: "B", payloadType: nil), Runtime.Case(name: "C", payloadType: nil)], numberOfEnumCases: 3, numberOfPayloadEnumCases: 0, genericTypes: [])

This is probably just a misunderstanding of mine, but I thought the payload for the A case would be "test"?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions