From 195533e7ace56c834a16b3222a68a2fa28cf88f0 Mon Sep 17 00:00:00 2001 From: Garrison Jensen Date: Tue, 7 May 2024 15:14:59 -0700 Subject: [PATCH] Use consistant naming for operators --- lib/sorted_containers/sorted_array.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/sorted_containers/sorted_array.rb b/lib/sorted_containers/sorted_array.rb index 3f88c99..8eb3f44 100644 --- a/lib/sorted_containers/sorted_array.rb +++ b/lib/sorted_containers/sorted_array.rb @@ -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. # @@ -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]