elixir中的truth和true

在elixir中, true 就是true 或者是:true 是一个原子 atom, 

在其他语言中的true,这里叫做truth, 只要你不是false,nil ,就是truth, 当然 false和nil也是原子

所以说elixir中Boolean operators 是针对true

  

a or b # true if a is true, otherwise b
a and b # false if a is false, otherwise b
not a  # false if a is true, true otherwise

Relaxed Boolean operators 是针对truth使用

a || b # a if a is truthy, otherwise b
a && b # a if a is truthy, otherwise b
!a # a if a is truthy, otherwise b

原文地址:https://www.cnblogs.com/or2-/p/7242629.html