elixir中的truth和true

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

在其余语言中的true,这里叫作truth, 只要你不是false,nil ,就是truth, 固然 false和nil也是原子elixir

 

因此说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使用

opera

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

相关文章
相关标签/搜索