A collection of learnings, coding adventures and random thoughts about living life.

In Ruby, you can simply negate an expression by using "!"

abc = 'abc'
!abc #=> false


abc = 'abc'

!abc #=> false
!!abc #=> true

Ruby's double-bang negates the negated statement, which almost always will give you true.

a = 0
b = 1
c = true
d = false

!a #=> false
!!a #=> true
!b #=> false
!!b #=> true
!c #=> false
!!c #=> true
!d #=> true
!!d #=> false

So be careful using the double bang to test for truth. Better test with positive equality in your conditions over using the double bang.