What is the difference between . (dot) and $ (dollar sign)?

后端 未结 13 1997
庸人自扰
庸人自扰 2020-11-22 04:57

What is the difference between the dot (.) and the dollar sign ($)?

As I understand it, they are both syntactic sugar for not needing to us

13条回答
  •  不知归路
    2020-11-22 05:18

    My rule is simple (I'm beginner too):

    • do not use . if you want to pass the parameter (call the function), and
    • do not use $ if there is no parameter yet (compose a function)

    That is

    show $ head [1, 2]
    

    but never:

    show . head [1, 2]
    

提交回复
热议问题