<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
	>
<channel>
	<title>Comments on: Hash Transforms in Ruby</title>
	<atom:link href="http://avdi.org/devblog/2009/11/20/hash-transforms-in-ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://avdi.org/devblog/2009/11/20/hash-transforms-in-ruby/</link>
	<description>"...the three great virtues of a programmer: laziness, impatience, and hubris." -- Larry Wall</description>
	<lastBuildDate>Wed, 03 Mar 2010 21:56:22 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: avdi</title>
		<link>http://avdi.org/devblog/2009/11/20/hash-transforms-in-ruby/comment-page-1/#comment-769</link>
		<dc:creator>avdi</dc:creator>
		<pubDate>Fri, 20 Nov 2009 13:34:23 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/?p=357#comment-769</guid>
		<description>Yeah, the whole &quot;returning an Array of Arrays&quot; business is a weird wart and IMO violates the POLS.</description>
		<content:encoded><![CDATA[<p>Yeah, the whole &#8220;returning an Array of Arrays&#8221; business is a weird wart and <span class="caps">IMO </span>violates the <span class="caps">POLS.</span></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: avdi</title>
		<link>http://avdi.org/devblog/2009/11/20/hash-transforms-in-ruby/comment-page-1/#comment-770</link>
		<dc:creator>avdi</dc:creator>
		<pubDate>Fri, 20 Nov 2009 13:34:23 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/?p=357#comment-770</guid>
		<description>Yeah, the whole &quot;returning an Array of Arrays&quot; business is a weird wart and IMO violates the POLS.</description>
		<content:encoded><![CDATA[<p>Yeah, the whole &#8220;returning an Array of Arrays&#8221; business is a weird wart and <span class="caps">IMO </span>violates the <span class="caps">POLS.</span></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: llimllib</title>
		<link>http://avdi.org/devblog/2009/11/20/hash-transforms-in-ruby/comment-page-1/#comment-768</link>
		<dc:creator>llimllib</dc:creator>
		<pubDate>Fri, 20 Nov 2009 13:28:18 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/?p=357#comment-768</guid>
		<description>When I was transitioning to Ruby from Python et al, the difficulty of doing this was remarkable to me. In python, it&#039;s just:&lt;br&gt;&lt;br&gt;In [1]: x = {1:2, 3:4, 5:6, 7:8, 9:0}&lt;br&gt;&lt;br&gt;In [2]: dict((str(k), v) for k,v in x.iteritems())&lt;br&gt;&lt;br&gt;Out[2]: {&#039;1&#039;: 2, &#039;3&#039;: 4, &#039;5&#039;: 6, &#039;7&#039;: 8, &#039;9&#039;: 0}&lt;br&gt;&lt;br&gt;So the equivalent function, adding the &quot;deep&quot; option, would be:&lt;br&gt;&lt;br&gt;def dict_transform(a_dict, f, deep=False):&lt;br&gt;    return dict(f(k,v) if not deep or not isinstance(v, dict) else f(k, dict_transform(v, f, deep))&lt;br&gt;                         for k,v in a_dict.iteritems())</description>
		<content:encoded><![CDATA[<p>When I was transitioning to Ruby from Python et al, the difficulty of doing this was remarkable to me. In python, it&#39;s just:</p>
<p>In [1]: x = {1:2, 3:4, 5:6, 7:8, 9:0}</p>
<p>In [2]: dict((str(k), v) for k,v in x.iteritems())</p>
<p>Out<sup class="footnote"><a href="#fn2">2</a></sup>: {&#39;1&#39;: 2, &#39;3&#39;: 4, &#39;5&#39;: 6, &#39;7&#39;: 8, &#39;9&#39;: 0}</p>
<p>So the equivalent function, adding the &#8220;deep&#8221; option, would be:</p>
<p>def dict_transform(a_dict, f, deep=False):<br />    return dict(f(k,v) if not deep or not isinstance(v, dict) else f(k, dict_transform(v, f, deep))<br />                         for k,v in a_dict.iteritems())</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: avdi</title>
		<link>http://avdi.org/devblog/2009/11/20/hash-transforms-in-ruby/comment-page-1/#comment-767</link>
		<dc:creator>avdi</dc:creator>
		<pubDate>Fri, 20 Nov 2009 13:18:20 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/?p=357#comment-767</guid>
		<description>Part of the impetus for writing mine was I tend to get the &lt;code&gt;Hash[*...]&lt;/code&gt; bit wrong... e.g. I&#039;ll leave out the splat.</description>
		<content:encoded><![CDATA[<p>Part of the impetus for writing mine was I tend to get the <code>Hash[*...]</code> bit wrong&#8230; e.g. I&#39;ll leave out the splat.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jjulian</title>
		<link>http://avdi.org/devblog/2009/11/20/hash-transforms-in-ruby/comment-page-1/#comment-766</link>
		<dc:creator>jjulian</dc:creator>
		<pubDate>Fri, 20 Nov 2009 13:14:07 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/?p=357#comment-766</guid>
		<description>Funny, I just googled and wrote a one-liner last night to transform keys AND values to strings.&lt;br&gt;&lt;br&gt;    Hash[*h.map {&#124;k,v&#124; [k.to_s,v.to_s] }.flatten]&lt;br&gt;&lt;br&gt;Not as robust as your examples, but a quick way since I know my input is flat.</description>
		<content:encoded><![CDATA[<p>Funny, I just googled and wrote a one-liner last night to transform keys <span class="caps">AND </span>values to strings.</p>
<p>    Hash[*h.map {|k,v| [k.to_s,v.to_s] }.flatten]</p>
<p>Not as robust as your examples, but a quick way since I know my input is flat.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.794 seconds -->
