<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>h4x &#187; fail</title>
	<atom:link href="http://h4x.co.uk/tag/fail/feed/" rel="self" type="application/rss+xml" />
	<link>http://h4x.co.uk</link>
	<description>The useless ramblings of a web developer.</description>
	<lastBuildDate>Tue, 10 Aug 2010 09:32:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Thanks Ruby &#8211; Array zip fail</title>
		<link>http://h4x.co.uk/2008/12/12/thanks-ruby-array-zip-fail/</link>
		<comments>http://h4x.co.uk/2008/12/12/thanks-ruby-array-zip-fail/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 16:33:07 +0000</pubDate>
		<dc:creator>Jamie</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[fail]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://h4x.co.uk/?p=33</guid>
		<description><![CDATA[After updating rails from 2.0.2 to 2.2.2 on the bit-tech CMS this week I discovered a bug that had cropped up in one of my controllers where I was calling zip to join a a has_many collection with a couple of arrays and iterate through them. The code that was working fine now did something [...]]]></description>
			<content:encoded><![CDATA[<p>After updating rails from 2.0.2 to 2.2.2 on the bit-tech CMS this week I discovered a bug that had cropped up in one of my controllers where I was calling zip to join a a has_many collection with a couple of arrays and iterate through them. The code that was working fine now did something like the following.</p>
<p><span style="font-family: -webkit-monospace;">&gt;&gt; g.groups.zip([1,2], [3,4]) {|a,b,c| p a.inspect + &#8216;, &#8216; + b.inspect + &#8216;, &#8216; + c.inspect }<br />
&#8220;[#&lt;Group id: 1&gt;, 1, 3], nil, nil&#8221;<br />
&#8220;[#&lt;Group id: 2&gt;, 2, 4], nil, nil&#8221;</span></p>
<p>This is strange, I can no longer access the three elements of the array directly in the block. So I tried the following</p>
<p><span style="font-family: -webkit-monospace;">&gt;&gt; g.groups.to_a.zip([1,2], [3,4]) {|a,b,c| p a.inspect + &#8216;, &#8216; + b.inspect + &#8216;, &#8216; + c.inspect }<br />
&#8220;#&lt;Group id: 1&gt;, 1, 3&#8243;<br />
&#8220;#&lt;Group id: 2&gt;, 2, 4&#8243;</span></p>
<p>As you can see this solved the problem, but I was confused why there was a difference so I executed&#8230;</p>
<p><span style="font-family: -webkit-monospace;">&gt;&gt; g.groups.class<br />
=&gt; Array</span></p>
<p>Why when I cast it to an Array, from an Array, is it acting differently? Rails must have done something to the Array class that is returned by the has_many relationship.</p>
]]></content:encoded>
			<wfw:commentRss>http://h4x.co.uk/2008/12/12/thanks-ruby-array-zip-fail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8230; game development</title>
		<link>http://h4x.co.uk/2008/10/01/game-development-2/</link>
		<comments>http://h4x.co.uk/2008/10/01/game-development-2/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 13:42:17 +0000</pubDate>
		<dc:creator>Jamie</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[fail]]></category>

		<guid isPermaLink="false">http://h4x.co.uk/?p=27</guid>
		<description><![CDATA[Well that didn&#8217;t even get off the ground. I&#8217;m now busy trying get more airtime on my mountain bike.]]></description>
			<content:encoded><![CDATA[<p>Well that didn&#8217;t even get off the ground.</p>
<p>I&#8217;m now busy trying get more airtime on my mountain bike.</p>
]]></content:encoded>
			<wfw:commentRss>http://h4x.co.uk/2008/10/01/game-development-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
