From: Michael Linfield Date: 2007-09-28T04:34:46+09:00 Subject: Re: gsub-ing each character yermej@gmail.com wrote: > Sorry, more mistakes. I'm giving up after this. > > subs = { > 'h' => '00', > 'i' => '01', > 'j' => '02', > } > > words = gets.chomp > new = subs.inject(words) {|acc, sub| acc.gsub(sub[0], sub[1])} unless > words.nil? > > or: > > words = gets.chomp > new = words.gsub('h', '00').gsub('i', '01').gsub('j', '02') unless > words.nil? > > Hopefully that's right. > > Jeremy Haha no worries, thanks a ton -- didnt know you could chain gsubs but now i think ill go with the inject method cause yes you were right when you talked about maintaining it. -- Posted via http://www.ruby-forum.com/.