Array#==() is an Array class method which performs the comparison between the two arrays. It checks whether the two arrays are equal or not.
Syntax: Array.==()
Parameter: Array for the comparison
Return: true : if arrays are equal
false : if arrays are not equal
Example #1 :
a = [ 18 , 22 , 33 , 4 , 5 , 6 ]
b = [ 18 , 22 , 33 , 4 , 5 , 6 ]
c = [ 18 , 22 , 33 , 40 , 50 , 6 ]
puts "comparison : #{a == b}\n\n"
puts "comparison : #{a == c}\n\n"
puts "comparison : #{b == c}\n\n"
|
Output :
comparison : true
comparison : false
comparison : false
Example #2 :
a = [ "abc" , "xyz" , "dog" ]
b = [ "cat" , "cat" , "dog" ]
c = [ "cat" , "cat" , "dog" ]
puts "comparison : #{a == b}\n\n"
puts "comparison : #{a == c}\n\n"
puts "comparison : #{b == c}\n\n"
|
Output :
comparison : false
comparison : false
comparison : true
Last Updated :
07 Jan, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...