From: "yermej@..." Date: 2007-09-28T03:50:02+09:00 Subject: Re: gsub-ing each character On Sep 27, 1:43 pm, "yer...@gmail.com" wrote: Oops...made a couple mistakes in the assignment (or lack thereof): > subs = { > 'h' => '00', > 'i' => '01', > 'j' => '02', > > } > words = gets.chomp new = subs.inject(words) {|acc, sub| acc.gsub(sub[0], sub[1])} unless new.nil? or: words = gets.chomp new = words.gsub('h', '00').gsub('i', '01').gsub('j', '02') unless new.nil? > Jeremy