From: matz@... (Yukihiro Matsumoto) Date: 2002-07-08T23:57:23+09:00 Subject: Re: is there a better string.each? Hi, In message "Re: is there a better string.each?" on 02/07/08, George Ogata writes: |Well, "usefulness" depends on the application. And it seems that |sometimes, strings are better seen as arrays (not Arrays!) of characters, |and at other times, as arrays of lines (and at yet other times, as arrays |of words or paragraphs). Agreed. |Since there doesn't seem to be a universally happy medium, perhaps the |problem lies in assuming there is one. I think the method "each" is the |problem: it's ambiguous ("each what?"). If the name "each" is the problem, it is the problem that costs just a few bits in your brain, so it's virtually nothing at all. |Couldn't we have separate methods (as suggested earlier) #bytes, #chars (or |#characters), #words (maybe), #lines, #pars (or #paragraphs) for String? Possible. |We have methods corresponding to the iterator/collector methods to set the |one that #each points to: #useBytes, #useChars (or #useCharacters), |#useWords, #useLines, #usePars (or #useParagraphs). I believe introducing another state to strings is a bad idea. Instead, parameterized mix-in (e.g. include Enumerable using each_byte as each) is a interesting idea, but it should be pretty hard to implement. matz.