Last Updated: February 25, 2016
·
543
· jiren

Simplified conditions for Array or any Enumerable objects

1.9.3-p0 :009 > a = [1]
=> [1]  

1.9.3-p0 :010 > p 'not empty' if a.any?
=> "not empty"

1.9.3-p0 :006 > a = []
=> []   

1.9.3-p0 :007 > p 'empty' if a.empty?
=> "empty"

1.9.3-p0 :012 > [1,nil].all?
=> false 

1.9.3-p0 :013 > [1,2].all?
=> true