From: matz@... (Yukihiro Matsumoto) Date: 2000-04-01T23:24:27+09:00 Subject: [ruby-talk:02331] Re: Function of Array.filter surprises me Hi, In message "[ruby-talk:02330] Function of Array.filter surprises me" on 00/04/01, mrilu writes: |I don't expect Array.filter to do task of Array.replace_with!. |I would expect it to be alias for Enumerable.select (or it's alias |find_all), that is filter or select all the elements satisfying |given condition. I have to admit `filter' is not a best name; some proposed `collect!', but I don't feel it's not collecting anything. |Moreover it is change-in-place function so wonder where lurks missing |exclamation mark? As you see, Enumerable.select don't need any |exclamation, so illusory connection between these two is even greater. Unlike Scheme, not all change-in-place functions are named with exclamation mark. In Ruby, exclamation mark means `MORE dangerous', or `may cause surprise' than non-bang counterpart, i.g. in-place modification by `gsub!' may let you surprise, comparing copying `gsub'. |I could add that Enumerable.apply would be better name for collect, IMO. |And that Enumerable (among other things) is very nice, indeed. The names collect/select/detect is from Smalltalk. I feel the name `apply' focuses too much on side effect. matz.