Skip to content

Commit

Permalink
Use consistant naming for operators
Browse files Browse the repository at this point in the history
  • Loading branch information
GarrisonJ committed May 7, 2024
1 parent 6c4dcd1 commit 195533e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/sorted_containers/sorted_array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ def self.[](*args)
#
# @param other [SortedArray] The other array to union with.
# @return [SortedArray] The union of the two arrays.
def &(other)
def intersection(other)
new_instance = self.class.new
new_instance.update(to_a & other.to_a)
new_instance
end
alias intersection &
alias & intersection

# When non-negative, multiplies returns a new Array with each value repeated `int` times.
#
Expand Down Expand Up @@ -74,12 +74,12 @@ def +(other)
#
# @param other [SortedArray] The other array to subtract.
# @return [SortedArray] The difference of the two arrays.
def -(other)
def difference(other)
new_instance = self.class.new
new_instance.update(to_a - other.to_a)
new_instance
end
alias difference -
alias - difference

# Returns -1, 0, or 1 as self is less than, equal to, or greater than other. For each index i in self,
# evaluates self[i] <=> other[i]
Expand Down

0 comments on commit 195533e

Please sign in to comment.