From: Austin Ziegler Date: 2003-04-09T00:52:55+09:00 Subject: Re: Array Sutraction On Tue, 8 Apr 2003 23:33:17 +0900, Jim Freeze wrote: > On Tuesday, 8 April 2003 at 22:59:50 +0900, Michael Campbell wrote: >>> I don't find this confusing. In fact I find the implicit >>> application of uniq (older version) more confusing because it is >>> somewhat surprising - at least to me. In that case substraction >>> indeed combines two operations. >>> >>> I'd view the substraction "a-b" as "remove all elements in b >>> from a", which would reasonable lead to all 2's removed from >>> [1,1,2,2,2] yielding [1,1]. >> So [1, 1, 2, 2] - [2] should yield the same as >> [1, 1, 2, 2] - [2, 2]? >> That seems odd to me. > Yes. It's not really subtraction as implied by the '-' minus > operator. Maybe it should be renamed to #remove_all_from. :) I think it's more confusing when dealing with numbers than with Objects. i = Object.new # => # j = Object.new # => # k = Object.new # => # a = [i, j, k, i, i] a - [i] # => [j, k] [i].each { |e| a.delete(e) } # => [j, k] You're removing a specific Object from an array. At least, IMO. -austin -- Austin Ziegler, austin@halostatue.ca on 2003.04.08 at 11:48