Ruby - Find if all the elements in the array are same
<array>.uniq.length == 1
# Example
a = [1,1,1]
a.uniq.length == 1
=> true
a = [1,1,2]
a.uniq.length == 1
=> false
Written by nava teja tummalapalli
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#