If statement is simple and every body has ground knowledge of what and how to use. I guess everybody has knowledge of using Boolean Expression in IF statement.
However the tricky part is, we need to think differently while writing Boolean Expression in UNLESS statement.
if x == 1 && y == 2 // Do Something when conditions meet end
If you want to do same job when conditions do not meet at all using UNLESS
unless x == 1 && y == 2 // Do Something when conditions meet end
This is WRONG!!
unless x == 1 || y == 2 // Do Something when conditions meet end
Think the Boolean Algebra
In electrical and computer engineering, De Morgan’s laws are commonly written as:
- is a logical AND
- is a logical OR
- the overbar is the logical NOT of what is underneath the overbar.