#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.
I didn’t actually want to change the array items themselves, just use
the results of the block for the join. If there was no block it
would work just as it does now joining the array element directly.
I have only used Ruby for a couple of weeks and I have used this type
of thing at least a few times. collect then join works, I just
thought it would be faster and use less memory if join took a block
and did it directly.
It would also seem similar to me to the way that sort works. Without
a block sort uses <=> but if given a block it will use the results of
that for the sorting. I was looking for the same basic functionality
for join.
Thanks,
Walt
···
Walter Szewelanczyk
IS Director
M.W. Sewall & CO. email : walter@mwsewall.com
259 Front St. Phone : (207) 442-7994 x 128
Bath, ME 04530 Fax : (207) 443-6284