From: Arun Kumar Date: 2009-04-29T22:21:18+09:00 Subject: Re: Random Access using IO#pos in code blocks --001e680f1e2453ca8c0468b17432 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable > > > Or perhaps you set freq =3D Hash.new(0), which is wrong in this case, > because the default element needs to be [0] not 0. > > An alternative is to auto-initialize each hash element like this: > > freq =3D Hash.new { |h,k| h[k] =3D [0] } > %w{foo bar baz bar}.each do |word| > freq[word][0] +=3D 1 > freq[word] << "pos" << "name" > end > puts freq.inspect > -- > Posted via http://www.ruby-forum.com/. > > Exactly the mistake I had done! So silly of me! Thank you SO MUCH := ) --=20 || =E0=A4=B6=E0=A5=8D=E0=A4=B0=E0=A5=80 =E0=A4=9C=E0=A4=BE=E0=A4=A8=E0=A4= =95=E0=A5=80=E0=A4=B0=E0=A4=98=E0=A5=81=E0=A4=A8=E0=A4=BE=E0=A4=A5=E0=A5=8B= =E0=A4=B5=E0=A4=BF=E0=A4=9C=E0=A4=AF=E0=A4=A4=E0=A5=87 || --001e680f1e2453ca8c0468b17432--