Erlang style - case vs function pattern matching

后端 未结 6 1612
眼角桃花
眼角桃花 2020-12-31 02:39

I\'ve got to the stage where I\'ve written quite a bit of Erlang code now, and I can see some style (bad or good) creeping into the way I\'ve been writing it. This particula

6条回答
  •  無奈伤痛
    2020-12-31 02:49

    Learn you some Erlang for great good has a small section on when to choose case and when to use a function. Two things are mentioned:

    1. They are represented in the same way in the VM so there is no difference in performance between the two solutions.

    2. If you need to use guards against more than one arguments, using a function may read better.

    All in all, it is mostly a question of style and taste.

提交回复
热议问题