yermej
9/27/2007 6:47:00 PM
On Sep 27, 1:43 pm, "yer...@gmail.com" <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