From: Phrogz Date: 2007-01-13T01:15:06+09:00 Subject: Re: DRY gsub... Josselin wrote: > I wrote the following ruby statements.. I get the result I need , I > tried to DRY it for 2 hours without being successfull , > > d = d.gsub(/\r\n/,' ') # get rid of carriage return > d = d.gsub(/;/,' ') # replace column by space > d = d.gsub(/,/,' ') # replace comma by space > a = d.split(' ') # split into component , space as divider BTW, that is already reasonably DRY, in my opinion. Calling the same method repeatedly but with different parameters is not "repeating yourself". It would be WET (hrm...Way Extra Toomuchcode) if you had something like: d = d.gsub( /\r\n/, ' ' ) e = e.gsub( /\r\n/, ' ' ) f = f.gsub( /\r\n/, ' ' ) g = g.gsub( /\r\n/, ' ' ) etc. It's just semantics, but IMO what you're asking for is to make your code more compact (but not necessarily golfing).