From: Loga Ganesan Date: 2009-04-06T23:32:58+09:00 Subject: Re: String.split crashes my program Tomas Na wrote: > I am trying to split a string by spaces and then loop through each > entry, adding it to an array if it is more then 4 characters long and > not already in the array. > > I haven't got very far with it, but I have come up against this problem > where split just crashes my program with no errors. > > def GetUniqueTextValues(sText) > aTags = Array.new > > puts sText > aTags = sText.split > puts sText > > return aTags > end > > What happens when I run this is the text is output for the first puts, > but not for the second. If I comment out the split then the text is > output twice, once for each puts. I read in the ruby docs that split > with no parameters will split by space, but I also tried split(' ') and > split(/ /) with the same crashing effect. I use split another place in > my program like this: > > saHeadParts = line.split(/: /) > > and it works fine, so I don't understand why it wont work this time. Can > anyone help me fix this? Its working for me. But I couldn't get your actual problem. If you give me further details as like your code, your ruby version, It would be useful for me to track the problem. -- Posted via http://www.ruby-forum.com/.