From: Chris Pine Date: 2003-03-29T00:07:56+09:00 Subject: Re: Array question ----- Original Message ----- From: "Daniel Carrera" On Fri, Mar 28, 2003 at 06:00:59PM +0900, Yukihiro Matsumoto wrote: > |#I want to do this > |puts list.join(","){|item| item.downcase} > | > |#but I have to do this > |puts list.collect{|item| item.downcase}.join(",") > > Hmm, I feel like this filtering is not part of "join" operation. > But I'm interested in how others think. > > matz. Uh, no it doesn't strike me as what 'join' is supposed to do. Intuitively, I think that a 'join' function should only join the entries of the array and not modify the entries themselves. --------------------------- That was `collect', not `collect!'; the array entries would not be modified. Matz comment was interesting. Do I feel like it is part of the join operation? No, I don't, but that's not the question I would ask. Currently, the block is totally ignored by #join: irb(main):001:0> arr = ['A', 'B'] ["A", "B"] irb(main):002:0> arr.join(","){|item| item.downcase} "A,B" Is this the most meaningful (dare I say "expected"?) behavior? I think the above is perfectly readable, clear code. So to me, the real question is, "Does it make more sense to ignore the block or to use it as outlined above?" (I like the idea.) Chris (the blockophile who would probably add a block to #reverse if given a chance :)