Created
February 19, 2014 19:45
-
-
Save emad-elsaid/9100042 to your computer and use it in GitHub Desktop.
multiple equal in ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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