Skip to content

Instantly share code, notes, and snippets.

@emad-elsaid
Created February 19, 2014 19:45
Show Gist options
  • Save emad-elsaid/9100042 to your computer and use it in GitHub Desktop.
Save emad-elsaid/9100042 to your computer and use it in GitHub Desktop.
multiple equal in ruby
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment