On Tue, 24 Feb 2004 06:59:10 +0900, "Jim Weirich"
<jim / weirichhouse.org> wrote:
>David MacQuigg said:
>> Here is what I would like to say in Python, but can't because
>> line.split() produces a list, and the subsequent methods don't apply
>> to lists.  I'll bet this would work in Ruby, but I don't know enough
>> Ruby to say for sure.
>>
>> file, length, name, title = line.split('|').strip.split.join()
>>
>> The goal is to produce a list of strings with whitespace and newlines
>> stripped off the ends, and whitespace squeezed out of the middle of
>> each string.
>
>Is this what you want ...
>
>file, length, name, title = line.split('|').collect{|it| t.squeeze.strip}

Yes.  That works if I change the 'it' to 't'.  Looks like the
'collect' method is equivalent to Python's 'map' function.  This
statement is still not as simple as I would like, but it definitely
beats the equivalent Python.

This is the first example I've seen where the difference between Ruby
and Python is more than just personal preference.  Thanks.

-- Dave