dblack / superlink.net wrote:
> On Sat, 3 May 2003, Andreas Schwarz wrote:
> 
>> Hello,
>>
>> I'm using the following code to read and chomp the content of a few
>> elements from REXML. The problem is that I get an exception when an
>> element is empty (<element></element>) because .text returns nil then.
>> How can I solve this problem without writing large if-constructions?
>>
>> @company = customer.elements["company"].text.chomp
>> @salutation =customer.elements["salutation"].text.chomp
> 
> You could throw in a to_s:
> 
>   ....text.to_s.chomp
> 
> (since nil.to_s is "")

I already thought about this, but I thought nil.to_s would return
"nil"... stupid... should have tried it before.

Thanks!