- 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.
推薦閱讀
- Getting started with Google Guava
- ThinkPHP 5實戰
- MySQL 8從入門到精通(視頻教學版)
- iOS 9 Game Development Essentials
- R語言數據可視化之美:專業圖表繪制指南
- 我的第一本算法書
- Learning Linux Binary Analysis
- HTML5 and CSS3 Transition,Transformation,and Animation
- Hands-On Microservices with Kotlin
- Go并發編程實戰
- Learning OpenCV 3 Computer Vision with Python(Second Edition)
- Android玩家必備
- 從零開始學C#
- 基于SpringBoot實現:Java分布式中間件開發入門與實戰
- Java Web應用開發項目教程