eql? returns true if the objects are the same or if their content is the same. : Compare Array « Array « Ruby






eql? returns true if the objects are the same or if their content is the same.

# eql? checks to see if the values are equal (as in ==), but also checks if the values are of the same type.

myArray1 = [ "full", 40, "yes" ]
myArray2 = ["part", 23, "no"]
myArray3 = [ "full", 40, "yes" ]

myArray1 == myArray3 # => true
myArray1.eql?( "full, 40, yes" ) # => false, myArray1 is not a string

 








Related examples in the same category

1.Comparing Arrays
2.compare arrays is with <=> (spaceship operator).
3.Comparison: Returns an integer -1,0, or +1, if this array is less than, equal to, or greater than other_array.
4.Equality: equal if they contain the same number of elements and if each element is equal to the corresponding element in the other array.