On Jun 26, 2007, at 7:45 AM, Frank Church wrote:

> Morton Goldberg wrote:
>> You could have saved yourself a lot trouble by using
>>
>>     puts "hashkey value is #{rubyhash["hashkey"]}"
>>
>> Regards, Morton
>
> I am learning Ruby step by step. There appear to be so many different
> ways of achieving the same thing, coming from a more procedural
> background, there are quite a number of things about the Ruby way I  
> have
> to learn.

The point to note about 'puts "hashkey value is #{rubyhash 
["hashkey"]}"' is that the interpreter calls to_s on the result of a # 
{...} evaluation, but String#+ is picky about is argument -- the  
argument must be a string. That means, as you have found out, that  
you must explicitly coerce anything not a string with to_s before  
passing it to String#+.

Regards, Morton