- 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.
推薦閱讀
- 計算機網絡
- Rust編程:入門、實戰與進階
- C#完全自學教程
- OpenNI Cookbook
- HTML5游戲開發案例教程
- 用Python實現深度學習框架
- 微服務架構深度解析:原理、實踐與進階
- OpenStack Networking Essentials
- CodeIgniter Web Application Blueprints
- C#程序設計基礎入門教程
- 精通Spring:Java Web開發與Spring Boot高級功能
- Using Yocto Project with BeagleBone Black
- Getting Started with Web Components
- 零基礎入門學習C語言:帶你學C帶你飛
- Learning Akka