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?