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

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

主站蜘蛛池模板: 通州区| 襄垣县| 西乌珠穆沁旗| 水城县| 无锡市| 香格里拉县| 吉隆县| 六枝特区| 越西县| 防城港市| 咸丰县| 明水县| 砚山县| 湖北省| 漳浦县| 杨浦区| 丰宁| 林州市| 车险| 金堂县| 永丰县| 龙里县| 汤阴县| 莎车县| 板桥市| 尚义县| 耒阳市| 平远县| 讷河市| 新营市| 壤塘县| 横山县| 临夏县| 航空| 桦川县| 买车| 杭州市| 曲松县| 江西省| 伊吾县| 宾阳县|