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

  • 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.

主站蜘蛛池模板: 渑池县| 治县。| 庄河市| 阿克陶县| 贵溪市| 金塔县| 克拉玛依市| 会昌县| 许昌市| 吉林省| 克什克腾旗| 依安县| 聂拉木县| 黄石市| 忻城县| 苗栗市| 建湖县| 信丰县| 新宁县| 泌阳县| 清远市| 伊通| 抚州市| 新丰县| 那曲县| 青龙| 独山县| 雅安市| 花莲市| 启东市| 呼和浩特市| 彰化市| 伊春市| 阳谷县| 澄城县| 瓮安县| 屏边| 苍南县| 富川| 甘德县| 五大连池市|