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

前端 未结 4 1766
情歌与酒
情歌与酒 2021-02-19 09:43

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:24

    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
    

提交回复
热议问题