From: Yukihiro Matsumoto Date: 2008-12-05T02:56:39+09:00 Subject: Re: Enumerable#select used to return actual values Hi, In message "Re: Enumerable#select used to return actual values" on Fri, 5 Dec 2008 02:07:03 +0900, Trans writes: |> |> (1..10).collect{ |a| a * a if a > 5 }.compact |> |And that's exactly what I suggested for #compact, to take a block but |> |faster b/c it's one pass. |> |> I don't deny the existence of use case of such method (although I |> cannot think of any realistic one right now), but its name should not |> be #compact, since it does far more than compacting the receiver. | |Why do you say? Is not "compact conditionally on result of block" a |good meaning? As far as I understand, the word compact means removing empty spaces, not transforming elements. If you really want a method to transform elements and to remove some of them at once, in the standard class library, you have to coin the proper term. |The implementation I have also allows an optional argument to define |what is to be subjected to compacting. | | [1,2,3].compact(1) #=> [2,3] For me, Array#compact sounds more like #squeeze in String class. I think we have better term #remove, #delete, or #reject for that purpose. We should not overuse the term compact. Am I wrong, native speakers? matz.