🖥
Ruby | if and unless can both be written on one line
Example
'I found a truth.' if true unless false # => 'I found a truth.'
Use
You don't have to write extra negation (!) To connect the conditional expressions. The meaning becomes clear. The following is a redundant example.
'I found a truth.' if true && !false # => 'I found a truth.'
environment
- ruby 2.3.0
Original by
About
チャットメンバー募集
何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。
公開日時
2019-04-16
Discussion