Joel Pearson wrote in post #1131366:
> Jason Tao wrote in post #1131307:
>> tool_name = code_book[cmd.to_sym]
>>
>> The downside I see here is it returns nil instead of "" if there is no
>> matching.
>
> There's this option:
>
> tool_name = code_book[cmd.to_sym] || ''

I can't believe I missed this obvious option
Hash.new ''
or
Hash.new { |hash, key| hash[key]='' }

-- 
Posted via http://www.ruby-forum.com/.