Class: Array

Inherits:
Object show all
Defined in:
lib/extensions/array.rb

Instance Method Summary collapse

Instance Method Details

#equivalent?(other_array) ⇒ Boolean

Returns true if the two arrays elements are equal ignoring order Example:

[1,2].equivalent([2,1])    # => true
[1,2,3].equivalent([2,1])  # => false

Returns:

  • (Boolean)


6
7
8
9
# File 'lib/extensions/array.rb', line 6

def equivalent?(other_array)
  merged_array = self & other_array
  merged_array.size == self.size && merged_array.size == other_array.size
end