- 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.
推薦閱讀
- Facebook Application Development with Graph API Cookbook
- JavaScript 從入門到項目實踐(超值版)
- 神經網絡編程實戰:Java語言實現(原書第2版)
- 程序員考試案例梳理、真題透解與強化訓練
- Designing Hyper-V Solutions
- Rust Cookbook
- Learning Neo4j 3.x(Second Edition)
- Effective Python Penetration Testing
- INSTANT Mercurial SCM Essentials How-to
- Mastering JBoss Enterprise Application Platform 7
- Clojure Reactive Programming
- Python之光:Python編程入門與實戰
- Unity 2D Game Development Cookbook
- 軟件測試實用教程
- Java網絡編程實戰