<?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/"
		>
<channel>
	<title>Comments on: Rubyize this : 2nd edition</title>
	<atom:link href="http://www.rubyfleebie.com/rubyize-this-2nd-edition/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rubyfleebie.com/rubyize-this-2nd-edition/</link>
	<description>Because programming should be fun</description>
	<lastBuildDate>Fri, 10 Sep 2010 17:40:52 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: canadacubeyo</title>
		<link>http://www.rubyfleebie.com/rubyize-this-2nd-edition/comment-page-1/#comment-694</link>
		<dc:creator>canadacubeyo</dc:creator>
		<pubDate>Wed, 24 Sep 2008 15:59:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubyfleebie.com/rubyize-this-2nd-edition/#comment-694</guid>
		<description>canada ugly vacant frog green look head white vacant we america girl</description>
		<content:encoded><![CDATA[<p>canada ugly vacant frog green look head white vacant we america girl</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: usaglobalstu</title>
		<link>http://www.rubyfleebie.com/rubyize-this-2nd-edition/comment-page-1/#comment-691</link>
		<dc:creator>usaglobalstu</dc:creator>
		<pubDate>Wed, 24 Sep 2008 15:52:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubyfleebie.com/rubyize-this-2nd-edition/#comment-691</guid>
		<description>canada vacant australia england joke free apple mail busy cube england green black kitchen</description>
		<content:encoded><![CDATA[<p>canada vacant australia england joke free apple mail busy cube england green black kitchen</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Refactor my Code &#171; Marc-André Cournoyer&#8217;s blog</title>
		<link>http://www.rubyfleebie.com/rubyize-this-2nd-edition/comment-page-1/#comment-366</link>
		<dc:creator>Refactor my Code &#171; Marc-André Cournoyer&#8217;s blog</dc:creator>
		<pubDate>Wed, 26 Sep 2007 22:24:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubyfleebie.com/rubyize-this-2nd-edition/#comment-366</guid>
		<description>[...] have you seen on blogs the author asking to replace &gt; and &lt; with something else. Oh! and forget about indentation HTML eats those, Wordpress replace &quot; with some weird character, etc, etc and etc! [...]</description>
		<content:encoded><![CDATA[<p>[...] have you seen on blogs the author asking to replace &gt; and &lt; with something else. Oh! and forget about indentation HTML eats those, Wordpress replace &quot; with some weird character, etc, etc and etc! [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: RSL</title>
		<link>http://www.rubyfleebie.com/rubyize-this-2nd-edition/comment-page-1/#comment-331</link>
		<dc:creator>RSL</dc:creator>
		<pubDate>Wed, 01 Aug 2007 13:47:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubyfleebie.com/rubyize-this-2nd-edition/#comment-331</guid>
		<description>@ Eric: All the Ruby tutorials use Array#each [because they&#039;re teaching Ruby] but the Rails tutorials [and even the books, shame shame!] use for/in to attract programmers from other languages. It&#039;s one of my pet peeves as it conditions the new Rails/Ruby programmer to keep thinking in his/her old programming language. This neglect to understand Ruby and Rails trickles usually ends up creating what I &quot;lovingly&quot; refer to as FrankenModels, with code and structures that use Ruby but look more like a PHP program.

As far as do..end or braces, they&#039;re both very Ruby. The difference tends to be mostly stylistic, with braces being used more for short, one-line code blocks and do..end for blocks that take more code. Don&#039;t let this fool you into thinking they&#039;re the same though. When using variable assignment and the return value from a block, do...end will sometimes raise an error as it doesn&#039;t bind as tightly as braces do and the assignment can&#039;t properly determine what&#039;s going on. This doesn&#039;t happen a lot but when it does, you&#039;ll be glad you learned that braces bind tighter.</description>
		<content:encoded><![CDATA[<p>@ Eric: All the Ruby tutorials use Array#each [because they're teaching Ruby] but the Rails tutorials [and even the books, shame shame!] use for/in to attract programmers from other languages. It&#8217;s one of my pet peeves as it conditions the new Rails/Ruby programmer to keep thinking in his/her old programming language. This neglect to understand Ruby and Rails trickles usually ends up creating what I &#8220;lovingly&#8221; refer to as FrankenModels, with code and structures that use Ruby but look more like a PHP program.</p>
<p>As far as do..end or braces, they&#8217;re both very Ruby. The difference tends to be mostly stylistic, with braces being used more for short, one-line code blocks and do..end for blocks that take more code. Don&#8217;t let this fool you into thinking they&#8217;re the same though. When using variable assignment and the return value from a block, do&#8230;end will sometimes raise an error as it doesn&#8217;t bind as tightly as braces do and the assignment can&#8217;t properly determine what&#8217;s going on. This doesn&#8217;t happen a lot but when it does, you&#8217;ll be glad you learned that braces bind tighter.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://www.rubyfleebie.com/rubyize-this-2nd-edition/comment-page-1/#comment-330</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Wed, 01 Aug 2007 07:13:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubyfleebie.com/rubyize-this-2nd-edition/#comment-330</guid>
		<description>Thanks to RSL for pointing this out.

It actually was the first time I ever used &quot;for ... in ....&quot; instead of @songs.each{&#124;song&#124;   }
I just saw it in previous code, and gave it a try!
But in every Ruby tutorial I saw, .each has been used.

I didn&#039;t know &quot;for ... in ...&quot; was syntactic sugar for Array#each though...

Do you have any other examples of &quot;Rubyer&quot; code?

do..end vs {}
&quot;a&quot;</description>
		<content:encoded><![CDATA[<p>Thanks to RSL for pointing this out.</p>
<p>It actually was the first time I ever used &#8220;for &#8230; in &#8230;.&#8221; instead of @songs.each{|song|   }<br />
I just saw it in previous code, and gave it a try!<br />
But in every Ruby tutorial I saw, .each has been used.</p>
<p>I didn&#8217;t know &#8220;for &#8230; in &#8230;&#8221; was syntactic sugar for Array#each though&#8230;</p>
<p>Do you have any other examples of &#8220;Rubyer&#8221; code?</p>
<p>do..end vs {}<br />
&#8220;a&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: RSL</title>
		<link>http://www.rubyfleebie.com/rubyize-this-2nd-edition/comment-page-1/#comment-329</link>
		<dc:creator>RSL</dc:creator>
		<pubDate>Tue, 31 Jul 2007 21:11:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubyfleebie.com/rubyize-this-2nd-edition/#comment-329</guid>
		<description>@ Alex: Neither link_to nor to_proc are Ruby methods themselves but Railsisms. I stand by my statement that a preference for the for/in methodology usually belies a programmer who hasn&#039;t come to fully understand Ruby. For/in is syntactic sugar for Array#each, put there for programmers who can&#039;&#039;t or won&#039;t let go of programming habits they learned in other languages. Array#each is not only marginally faster but more importantly... it&#039;s more _Ruby_. And by learning to think in Ruby [instead of translating your old programming languages&#039; idioms to Ruby] one will no doubt see a marked increase in the efficiency of his/her code.</description>
		<content:encoded><![CDATA[<p>@ Alex: Neither link_to nor to_proc are Ruby methods themselves but Railsisms. I stand by my statement that a preference for the for/in methodology usually belies a programmer who hasn&#8217;t come to fully understand Ruby. For/in is syntactic sugar for Array#each, put there for programmers who can&#8221;t or won&#8217;t let go of programming habits they learned in other languages. Array#each is not only marginally faster but more importantly&#8230; it&#8217;s more _Ruby_. And by learning to think in Ruby [instead of translating your old programming languages' idioms to Ruby] one will no doubt see a marked increase in the efficiency of his/her code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://www.rubyfleebie.com/rubyize-this-2nd-edition/comment-page-1/#comment-326</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Mon, 30 Jul 2007 21:48:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubyfleebie.com/rubyize-this-2nd-edition/#comment-326</guid>
		<description>I don&#039;t really think its really an issue of not knowing Ruby. I just think the syntax of for x in y is nicer than y.each do &#124;x&#124;. While I take the point about it being marginally slower, this is true (often to a larger extent) of a large number of other widely used, convenient methods, like link_to or to_proc. It&#039;s just one of the downsides of Ruby I&#039;m afraid.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t really think its really an issue of not knowing Ruby. I just think the syntax of for x in y is nicer than y.each do |x|. While I take the point about it being marginally slower, this is true (often to a larger extent) of a large number of other widely used, convenient methods, like link_to or to_proc. It&#8217;s just one of the downsides of Ruby I&#8217;m afraid.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: RSL</title>
		<link>http://www.rubyfleebie.com/rubyize-this-2nd-edition/comment-page-1/#comment-325</link>
		<dc:creator>RSL</dc:creator>
		<pubDate>Mon, 30 Jul 2007 21:33:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubyfleebie.com/rubyize-this-2nd-edition/#comment-325</guid>
		<description>Wow. I find it kinda disheartening that only one out of thirteen solutions broke away from the PHP/JS for/in mindset and went with the much more native Ruby Array#each. The Ruby compiler has to translate those &quot;foreign&quot; phrases into Ruby&#039;s Array#each every time you use them. :( I really, really hate that so many &quot;Rubyists&quot; continue to baby-feed their students this ugly, clunky, fallback methodology. It&#039;s usually a telltale sign [to me] that someone doesn&#039;t really know their Ruby. :(</description>
		<content:encoded><![CDATA[<p>Wow. I find it kinda disheartening that only one out of thirteen solutions broke away from the PHP/JS for/in mindset and went with the much more native Ruby Array#each. The Ruby compiler has to translate those &#8220;foreign&#8221; phrases into Ruby&#8217;s Array#each every time you use them. :( I really, really hate that so many &#8220;Rubyists&#8221; continue to baby-feed their students this ugly, clunky, fallback methodology. It&#8217;s usually a telltale sign [to me] that someone doesn&#8217;t really know their Ruby. :(</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott</title>
		<link>http://www.rubyfleebie.com/rubyize-this-2nd-edition/comment-page-1/#comment-324</link>
		<dc:creator>Scott</dc:creator>
		<pubDate>Mon, 30 Jul 2007 18:29:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubyfleebie.com/rubyize-this-2nd-edition/#comment-324</guid>
		<description>Fun!  OK, here&#039;s mine.  Not much different from everyone else&#039;s, but I thought I&#039;d throw it in the ring.

First, in the controller:
@songs = Song.find(:all)

Second, in the migration that created songs, I&#039;d set the default for rating to 1 and make rating an int.  This gets rid of the need to check for nil in the rating.  I&#039;d think about validating for this in the model as well.

Here&#039;s the view:

% @songs.each do &#124;song&#124; %
  h2%= song.title.titleize %/h2
  %=  song.rating &gt; 0 ?  image_tag(&#039;star.gif&#039;) * rating : &quot;This song hasn&#039;t been rated yet&quot; %
% end %

I tend to use the trinary operator a lot, so I find  that readable.  Others may differ :)

Scott

Oh yeah, if you use image tag like that, you need to have star.gif in the public/images directory.  This seems more railsy to me.  If you really want it in public, then I think that calling it like image_tag(&#039;/star.gif&#039;) will do the trick.</description>
		<content:encoded><![CDATA[<p>Fun!  OK, here&#8217;s mine.  Not much different from everyone else&#8217;s, but I thought I&#8217;d throw it in the ring.</p>
<p>First, in the controller:<br />
@songs = Song.find(:all)</p>
<p>Second, in the migration that created songs, I&#8217;d set the default for rating to 1 and make rating an int.  This gets rid of the need to check for nil in the rating.  I&#8217;d think about validating for this in the model as well.</p>
<p>Here&#8217;s the view:</p>
<p>% @songs.each do |song| %<br />
  h2%= song.title.titleize %/h2<br />
  %=  song.rating &gt; 0 ?  image_tag(&#8217;star.gif&#8217;) * rating : &#8220;This song hasn&#8217;t been rated yet&#8221; %<br />
% end %</p>
<p>I tend to use the trinary operator a lot, so I find  that readable.  Others may differ :)</p>
<p>Scott</p>
<p>Oh yeah, if you use image tag like that, you need to have star.gif in the public/images directory.  This seems more railsy to me.  If you really want it in public, then I think that calling it like image_tag(&#8216;/star.gif&#8217;) will do the trick.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: macournoyer</title>
		<link>http://www.rubyfleebie.com/rubyize-this-2nd-edition/comment-page-1/#comment-323</link>
		<dc:creator>macournoyer</dc:creator>
		<pubDate>Mon, 30 Jul 2007 17:41:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubyfleebie.com/rubyize-this-2nd-edition/#comment-323</guid>
		<description>&lt;code&gt;
# Controller
def show
  @songs = Song.find(:all)
end

# Helper
def song_rating(song)
  if song.rating.to_i &gt; 0
    image_tag(&#039;star.gif&#039;) * song.rating.to_i
  else
    &quot;This song hasn’t been rated yet&quot;
  end
end

# View
&gt;% @songs.each do &#124;song&#124; %&lt;
  &gt;h2&lt;&gt;%=h song.title.capitalize %&lt;&gt;/h2&lt;
  &gt;%= song_rating song %&lt;
&gt;% end %&lt;

# Me
self.drink! :coffey
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p><code><br />
# Controller<br />
def show<br />
  @songs = Song.find(:all)<br />
end</p>
<p># Helper<br />
def song_rating(song)<br />
  if song.rating.to_i &gt; 0<br />
    image_tag('star.gif') * song.rating.to_i<br />
  else<br />
    "This song hasn’t been rated yet"<br />
  end<br />
end</p>
<p># View<br />
&gt;% @songs.each do |song| %&lt;<br />
  &gt;h2&lt;&gt;%=h song.title.capitalize %&lt;&gt;/h2&lt;<br />
  &gt;%= song_rating song %&lt;<br />
&gt;% end %&lt;</p>
<p># Me<br />
self.drink! :coffey<br />
</code></p>
]]></content:encoded>
	</item>
</channel>
</rss>
