class Array
Overwrites its equal operator
Public Instance Methods
==(other)
click to toggle source
Updated Array#==
This modifies the original equality operator so that it returns true when both self and other are practically empty, that is, if #empty_element?
and/or empty?
are true for both, they are equal.
This modification is necessary because {Rangeary#empty?} never returns true
; when it has no Range elements, it holds RangeExtd::NONE
or equivalent, in whih case {Rangeary#empty_element?} returns true
.
@param other [Object]
# File lib/rangeary.rb, line 1407 def ==(other) return true if equals_before_rangeary other # It was false. Is it? # eg., (Rangeary[RangeExtd::NONE] == []) is true, # because Rangeary[] with zero components does not exist! # Now either other or self is guranteed to be Rangeary. self_empt = (respond_to?(:empty_element?) ? empty_element? : empty?) other_empt = (other.respond_to?(:empty_element?) ? other.empty_element? : other.empty?) self_empt && other_empt end
Also aliased as: equals_before_rangeary