Comparison: Returns an integer -1,0, or +1, if this array is less than, equal to, or greater than other_array. : Compare Array « Array « Ruby






Comparison: Returns an integer -1,0, or +1, if this array is less than, equal to, or greater than other_array.



p [ "a", "a", "c" ] <=> [ "a", "b", "c" ]  
p [ 1,2, 3, 4,5, 6 ] <=>[ 1, 2 ]  

 








Related examples in the same category

1.Comparing Arrays
2.eql? returns true if the objects are the same or if their content is the same.
3.compare arrays is with <=> (spaceship operator).
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.