Ruby not-empty? method
Posted
by klew
on Stack Overflow
See other posts from Stack Overflow
or by klew
Published on 2010-05-20T15:18:17Z
Indexed on
2010/05/20
15:20 UTC
Read the original article
Hit count: 247
ruby
|refactoring
I want to use expression:
!([1,2,3] & [43,5]).empty?
=> false
!([1,2,3] & [3,5]).empty?
=> true
to check if two arrays contains at least one common value. And I wonder if there is a better way of doing it? Maybe something like:
([1,2,3] & [3,5]).non_empty?
How to write non_empty?
method?
© Stack Overflow or respective owner