官术网_书友最值得收藏!

  • Mastering Elixir
  • André Albuquerque Daniel Caixinha
  • 87字
  • 2021-08-05 10:42:49

if and unless

These two constructs can be used with the following syntax:

if <expression> do
# expression was truthy
else
# expression was falsy
end

unless <expression> do
# expression was falsy
else
# expression was truthy
end

As with the def construct, they can be inlined. For if, you'd do this:

if <expression>, do: # expression was truthy, else: # expression was falsy 

For both constructs, the else clause is optional. They will return nil if the main clause doesn't match and no else clause was provided.

主站蜘蛛池模板: 伊通| 甘泉县| 山阳县| 咸丰县| 垦利县| 双柏县| 淮安市| 仙游县| 界首市| 亳州市| 广灵县| 兰坪| 元阳县| 肇东市| 神木县| 汉川市| 滦平县| 北辰区| 轮台县| 阜平县| 东方市| 正镶白旗| 襄垣县| 庄河市| 江门市| 新营市| 闽侯县| 苍梧县| 巴南区| 呼伦贝尔市| 宿松县| 金堂县| 驻马店市| 凤阳县| 新营市| 潼南县| 政和县| 龙江县| 永靖县| 当阳市| 达拉特旗|