From: Tom Cloyd Date: 2008-06-16T16:58:28+09:00 Subject: how to stop gsub from returning nil I'm trying to use gsub to do a number of transformations in an array of strings. I find that when a particular transformation does NOT happen, because the searched-for substring is not there, gsub returns nil. This effectively ruins my output. I don't want nothing. I want the string that's being processed, returned with or without any transformations. Is there any alternative to testing for a return of nil before calling gsub, so as to avoid the wiping out of my string? I've looked for something to use other than String::gsub, and have not found anything. Code: filein = open( "{whatever}" ) fi = filein.readlines delta = [ ["

", ''], ["", ''] ] results = fi.collect do |x| delta.each do |y| debugger x.gsub!(y[0], y[1]) end end t. -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Tom Cloyd, MS MA, LMHC Private practice Psychotherapist Bellingham, Washington, U.S.A: (360) 920-1226 << tc@tomcloyd.com >> (email) << TomCloyd.com >> (website & psychotherapy weblog) << sleightmind.wordpress.com >> (mental health issues weblog) << directpathdesign.com >> (web site design & consultation) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~