How to enumerate an enum/type in F#

前端 未结 7 1998
攒了一身酷
攒了一身酷 2021-01-11 09:43

I\'ve got an enumeration type defined like so:

type tags = 
    | ART  = 0
    | N    = 1
    | V    = 2 
    | P    = 3
    | NULL = 4

is

7条回答
  •  再見小時候
    2021-01-11 10:00

    To make it an enum you need to explicitly give values to each case, otherwise it's a union type:

    type tags = 
        | ART = 0
        | N = 1
        | V = 2
        | P = 3
        | NULL= 4
    let allTags = System.Enum.GetValues(typeof)
    

提交回复
热议问题