Open zhulinpinyu opened 5 years ago
我更喜欢 常规写法 , 毫无心理负担。
哈哈, 有创意
and 也可以
iex(3)> find = fn(x) when x<10 and x>5 and x==7 -> x end
#Function<6.128620087/1 in :erl_eval.expr/5>
iex(4)> find.(7)
7
iex(5)> find = fn(x) when false not in [x<10, x>5, x==7] -> x end
#Function<6.128620087/1 in :erl_eval.expr/5>
iex(6)> find.(7)
7
常规写法
优化写法
Thanks: https://github.com/blackode/elixir-tips#1-multiple--or