--90e6ba6e8d584be40604a41655ba
Content-Type: text/plain; charset=UTF-8

On Tue, May 24, 2011 at 9:36 AM, Joey Zhou <yimutang / gmail.com> wrote:

> hash  ash.new {|h,k| k.to_s + "foo" }
> hash.add_keys("a","b","c") # the value is hash's default obj or proc value
>

If there's a default proc, I can't see why you'd need to create the keys
like this. If you did want to, can you not just use

keys.each { |k| hash[keys] }

?

For instance:

open("file").readlines.map(&:chomp).each { |k| hash[k] }

--90e6ba6e8d584be40604a41655ba
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div class="gmail_quote">On Tue, May 24, 2011 at 9:36 AM, Joey Zhou <spanir="ltr">&lt;yimutang / gmail.com&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:08ex;border-left:1px #ccc solid;padding-left:1ex;">

<div id=":1eu">hash = Hash.new {|h,k| k.to_s + &quot;foo&quot; }<br>
hash.add_keys(&quot;a&quot;,&quot;b&quot;,&quot;c&quot;) # the value is hash&#39;s default obj or proc value<br></div></blockquote></div><br><div>If there&#39;s a default proc, I can&#39;t see why you&#39;d need to create theeys like this. If you did want to, can you not just use</div>

<div><br></div><div>keys.each { |k| hash[keys] }</div><div><br></div><div>?</div><div><br></div><div>For instance:</div><div><br></div><div><meta charset="utf-8"><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">open(&quot;file&quot;).readlines.map(&amp;:chomp).each { |k| hash[k] }<br>

</span></div>

--90e6ba6e8d584be40604a41655ba--