Better to use “and” or “in” when chaining “let” statements?

前端 未结 4 1390
耶瑟儿~
耶瑟儿~ 2021-02-19 09:57

I realize this is probably a silly question, but...

If I\'m chaining a bunch of let statements which do not need to know each other\'s values, is it

4条回答
  •  走了就别回头了
    2021-02-19 10:03

    My opinion is that in is better. The use of and implies that the definitions are mutually dependent on each other. I think it is better to be clear that this is not the case. On the other hand, some OCaml programmers do prefer and for very short definitions, where the slightly more compact notation can appear cleaner. This is especially true when you can fit the definitions on a single line:

    let a = "foo" and b = "bar" in
    

提交回复
热议问题