How to check multiple variables for equality in #ruby the simple way
Join the DZone community and get the full member experience.Join For Free
class Array def same? uniq.length==1 end end x = 1 y = 2 z = 2 l = 2 # old way : x==y and y==z puts [x,y,z].same? # false # old way : y==z and z==l puts [y,z,l].same? # true
Opinions expressed by DZone contributors are their own.