F# explicit match vs function syntax

后端 未结 8 2477
耶瑟儿~
耶瑟儿~ 2020-12-04 23:21

Sorry about the vague title, but part of this question is what these two syntax styles are called:

let foo1 x = 
    match x with
    | 1 -> \"one\"
    |         


        
8条回答
  •  一个人的身影
    2020-12-04 23:24

    The match version is called a "pattern matching expression". The function version is called a "pattern matching function". Found in section 6.6.4 of the spec.

    Using one over the other is a matter of style. I prefer only using the function version when I need to define a function that is only a match statement.

提交回复
热议问题