根据这个被接受的答案,在F#和OCaml中,我需要使用下划线来丢弃记录中其余的部分。但是,为什么
handle'
函数可行而handle
函数不行?type Type = Type of int
type Entity =
{ type' : Type
foo : string }
let handle entities =
match entities with
| {type' = Type i; _ }::entites -> ()
| [] -> ()
let handle' entities =
match entities with
| {type' = Type i }::entites -> ()
| [] -> ()