<?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/"
	xmlns:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>Man With Code &#187; hashes</title>
	<atom:link href="http://manwithcode.com/tag/hashes/feed/" rel="self" type="application/rss+xml" />
	<link>http://manwithcode.com</link>
	<description>Teaching You, One Tutorial at a Time</description>
	<lastBuildDate>Tue, 22 Feb 2011 23:40:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Programming With Ruby Episode 8, Hashes</title>
		<link>http://manwithcode.com/132/programming-with-ruby-episode-8-hashes/</link>
		<comments>http://manwithcode.com/132/programming-with-ruby-episode-8-hashes/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 06:33:11 +0000</pubDate>
		<dc:creator>Tyler</dc:creator>
				<category><![CDATA[Ruby Programming]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[hashes]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://manwithcode.com/?p=132</guid>
		<description><![CDATA[Covered In This Episode: What are Hashes? Hash Creation Hash Accessing Hash iteration Hash Methods Transcript: Hello Everybody and welcome to Programming With Ruby Episode 8, Hashes. I&#8217;m Tyler,and this video is brought to you by, manwithcode.com In this episode I will be telling you what hashes are, how you can create them, access them, [...]]]></description>
			<content:encoded><![CDATA[<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/LIrTu1UDATk&#038;hl=en&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/LIrTu1UDATk&#038;hl=en&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
<p><strong>Covered In This Episode:</strong></p>
<ul>
<li>What are Hashes?</li>
<li>Hash Creation</li>
<li>Hash Accessing</li>
<li>Hash iteration</li>
<li>Hash Methods</li>
</ul>
<p><strong>Transcript:</strong></p>
<p>Hello Everybody and welcome to Programming With Ruby Episode 8,<br />
Hashes. I&#8217;m Tyler,and this video is brought to you by, manwithcode.com</p>
<p>In this episode I will be telling you what hashes are, how you can<br />
create them, access them, and iterate over them. Finally at the end I<br />
will show you some useful methods that hashes have.</p>
<p><strong>What Are Hashes?</strong></p>
<p>Hashes are like arrays, which you learned about in the previous<br />
episode. Except that they have no order, and instead of being accessed<br />
by an index number, they are accessed by what is called a key (which<br />
can be anything). That key points to a value, which is the actual data<br />
inside the hash</p>
<p>Arrays are used for lists of data, where hashes are used to relate<br />
data. I may have a hash where the keys are my friend&#8217;s names, and the<br />
values are their birthdays.</p>
<p><strong>Hash Creation</strong></p>
<p>Similarly to how arrays are created with square brackets, hashes are<br />
created with curly brackets:</p>
<pre class="brush: ruby; title: ; notranslate">
my_hash = {}
</pre>
<p>Items are defined like this:</p>
<pre class="brush: ruby; title: ; notranslate">
birthdays = {&quot;Amy&quot; =&gt; &quot;May&quot;, &quot;Dakota&quot; =&gt; &quot;January&quot;}
</pre>
<p>Each key-value pair are separated by a comma, and their relation is<br />
defined with =&gt;</p>
<p><strong>Accessing Hashes</strong></p>
<p>You can access hashes in almost the same way you access arrays, except<br />
by using the key value, instead of an index number:</p>
<pre class="brush: ruby; title: ; notranslate">
brithdays[&quot;Amy&quot;] #=&gt; May
</pre>
<p>You can define new keys and values:</p>
<pre class="brush: ruby; title: ; notranslate">
birthdays[&quot;Zack&quot;] = &quot;April&quot;
</pre>
<p><strong>Iterating Over Hashes</strong></p>
<p>Hashes have an each method like arrays do:</p>
<pre class="brush: ruby; title: ; notranslate">
my_hash = {&quot;cat&quot; =&gt; &quot;hat&quot;, &quot;dog&quot; =&gt; &quot;log&quot;}
my_hash.each do |pair|
	puts &quot;Key: &quot; + pair[0]
	puts &quot;Value: &quot; + pair[1]
end
#=&gt; Key: cat
#=&gt; Value: hat
#=&gt; Key: dog
#=&gt; Value: log
</pre>
<p>They also have each_key and each_value which let you iterate over each<br />
key or value in a similar way.</p>
<p><strong>Useful Hash Methods</strong></p>
<p><em>delete(key)</em> deletes a key-value pair<br />
<em>empty?</em> True or False if the hash is empty<br />
<em>keys</em> returns the keys<br />
<em>values</em> returns the values<br />
<em>size</em> how many key-value pairs there are</p>
<p>That wraps it up for this episode!</p>
<p>Please donate, or I will stop making these videos. There should be a<br />
link to donate to the right of this video.</p>
<p>If you have any questions or comments leave a comment on this page or<br />
email me at tyler@manwithcode.com</p>
<p>Thanks for watching, goodbye!</p>
]]></content:encoded>
			<wfw:commentRss>http://manwithcode.com/132/programming-with-ruby-episode-8-hashes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<series:name><![CDATA[Ruby Programming]]></series:name>
	</item>
	</channel>
</rss>

