DEV Community

Cover image for If statements
Felix Imbanga
Felix Imbanga

Posted on

If statements

Type end immediately after typing the if. Indent
elsif is only when you need to check more than 2 conditions.
Causing code to execute is known as 'truthy'
Causing code to not execute is known as 'falsy'
Only nil and false are falsy.
!= means not equivalent
p if for quick inspection, pp is for more human readable representations. especially with complex data structures.
In variables you can put methods on both sides to evaluate if statements more concise.
&& both statements have to be true
|| at least one statement has to be true.

Top comments (0)