<?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 for PHP to Ruby</title>
	<atom:link href="http://www.phptoruby.com/comments/feed" rel="self" type="application/rss+xml" />
	<link>http://www.phptoruby.com</link>
	<description>Convert PHP code into Ruby!</description>
	<pubDate>Thu, 29 Jul 2010 23:23:42 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>Comment on array_flip by RubyLove</title>
		<link>http://www.phptoruby.com/array_flip/comment-page-1#comment-2826</link>
		<dc:creator>RubyLove</dc:creator>
		<pubDate>Mon, 05 Jul 2010 23:18:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.phptoruby.com/array_flip#comment-2826</guid>
		<description>Thanks for pointing out the mistake, I have corrected it :)</description>
		<content:encoded><![CDATA[<p>Thanks for pointing out the mistake, I have corrected it <img src='http://www.phptoruby.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on array_flip by bakancs</title>
		<link>http://www.phptoruby.com/array_flip/comment-page-1#comment-2825</link>
		<dc:creator>bakancs</dc:creator>
		<pubDate>Mon, 05 Jul 2010 22:31:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.phptoruby.com/array_flip#comment-2825</guid>
		<description>in the first row of ruby code a syntax mistake... but good description!</description>
		<content:encoded><![CDATA[<p>in the first row of ruby code a syntax mistake&#8230; but good description!</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on is_numeric by Mike DiGioia</title>
		<link>http://www.phptoruby.com/is_numeric/comment-page-1#comment-2471</link>
		<dc:creator>Mike DiGioia</dc:creator>
		<pubDate>Tue, 20 Apr 2010 18:06:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.phptoruby.com/is_numeric#comment-2471</guid>
		<description>class String
 def is_numeric?
  self.strip =~ /^(-&#124;\+&#124;)[0-9]*(\.[0-9]+)?$/
 end 
end


p '123'.is_numeric?</description>
		<content:encoded><![CDATA[<p>class String<br />
 def is_numeric?<br />
  self.strip =~ /^(-|\+|)[0-9]*(\.[0-9]+)?$/<br />
 end<br />
end</p>
<p>p &#8216;123&#8242;.is_numeric?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on array_sum by Josso</title>
		<link>http://www.phptoruby.com/array_sum/comment-page-1#comment-2070</link>
		<dc:creator>Josso</dc:creator>
		<pubDate>Sun, 07 Mar 2010 18:14:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.phptoruby.com/array_sum#comment-2070</guid>
		<description>If you're not using Ruby on Rails, you can easily just make your own .sum :)

[code]
class Array; 
def sum; 
inject( nil ) { &#124;sum,x&#124; sum ? sum+x : x }; 
end; 
end
[/code]

The result will be the following:

[code]
[1,2,3].sum              # =&gt; 6
['1','2','3'].sum              # =&gt; 123
['a','b','c'].sum        # =&gt; 'abc'
[['a'], ['b','c']].sum   # =&gt; ['a', 'b', 'c']
[/code]

If you're not sure about the type of the array and only are using it with ints, you might want to replace sum+x with sum.to_i+x.to_i</description>
		<content:encoded><![CDATA[<p>If you&#8217;re not using Ruby on Rails, you can easily just make your own .sum <img src='http://www.phptoruby.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>[code]<br />
class Array;<br />
def sum;<br />
inject( nil ) { |sum,x| sum ? sum+x : x };<br />
end;<br />
end<br />
[/code]</p>
<p>The result will be the following:</p>
<p>[code]<br />
[1,2,3].sum              # =&gt; 6<br />
['1','2','3'].sum              # =&gt; 123<br />
['a','b','c'].sum        # =&gt; &#8216;abc&#8217;<br />
[['a'], ['b','c']].sum   # =&gt; ['a', 'b', 'c']<br />
[/code]</p>
<p>If you&#8217;re not sure about the type of the array and only are using it with ints, you might want to replace sum+x with sum.to_i+x.to_i</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on lcfirst by RubyLove</title>
		<link>http://www.phptoruby.com/lcfirst/comment-page-1#comment-1906</link>
		<dc:creator>RubyLove</dc:creator>
		<pubDate>Mon, 22 Feb 2010 15:52:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.phptoruby.com/lcfirst#comment-1906</guid>
		<description>Ruby has the 'minimal code' approach and makes the semi-colon optional.

I think PHP developers are more comfortable ending with semi-colon - Im not sure if this is a good thing, or if forcing them to move to Ruby standards is better.</description>
		<content:encoded><![CDATA[<p>Ruby has the &#8216;minimal code&#8217; approach and makes the semi-colon optional.</p>
<p>I think PHP developers are more comfortable ending with semi-colon - Im not sure if this is a good thing, or if forcing them to move to Ruby standards is better.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on lcfirst by christophe</title>
		<link>http://www.phptoruby.com/lcfirst/comment-page-1#comment-1903</link>
		<dc:creator>christophe</dc:creator>
		<pubDate>Mon, 22 Feb 2010 15:03:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.phptoruby.com/lcfirst#comment-1903</guid>
		<description>Not sure you want the semicolon at the end of the Ruby statement :)</description>
		<content:encoded><![CDATA[<p>Not sure you want the semicolon at the end of the Ruby statement <img src='http://www.phptoruby.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on crc32 by Cristian Livadaru</title>
		<link>http://www.phptoruby.com/crc32/comment-page-1#comment-1810</link>
		<dc:creator>Cristian Livadaru</dc:creator>
		<pubDate>Sat, 13 Feb 2010 20:23:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.phptoruby.com/crc32#comment-1810</guid>
		<description>Take care when comparing ruby results with php results. The php manual says: 

Because PHP's integer type is signed, and many crc32 checksums will result in negative integers, you need to use the "%u" formatter of sprintf() or printf()  to get the string representation of the unsigned crc32 checksum. 

So in case you have a negative number in PHP don't be afraid, it's not wrong! Display it with printf("%u",$checksum) and compare THAT result o the Ruby result !</description>
		<content:encoded><![CDATA[<p>Take care when comparing ruby results with php results. The php manual says: </p>
<p>Because PHP&#8217;s integer type is signed, and many crc32 checksums will result in negative integers, you need to use the &#8220;%u&#8221; formatter of sprintf() or printf()  to get the string representation of the unsigned crc32 checksum. </p>
<p>So in case you have a negative number in PHP don&#8217;t be afraid, it&#8217;s not wrong! Display it with printf(&#8221;%u&#8221;,$checksum) and compare THAT result o the Ruby result !</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on ucwords by Rasidee</title>
		<link>http://www.phptoruby.com/ucwords/comment-page-1#comment-1554</link>
		<dc:creator>Rasidee</dc:creator>
		<pubDate>Thu, 14 Jan 2010 03:09:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.phptoruby.com/ucwords#comment-1554</guid>
		<description>puts "ruby is easy".gsub(/\b\w/){&#124;s&#124;s.upcase}
=&gt; "Ruby Is Easy"</description>
		<content:encoded><![CDATA[<p>puts &#8220;ruby is easy&#8221;.gsub(/\b\w/){|s|s.upcase}<br />
=&gt; &#8220;Ruby Is Easy&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on is_numeric by RubyLove</title>
		<link>http://www.phptoruby.com/is_numeric/comment-page-1#comment-1118</link>
		<dc:creator>RubyLove</dc:creator>
		<pubDate>Sat, 07 Nov 2009 11:31:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.phptoruby.com/is_numeric#comment-1118</guid>
		<description>@jef

Your right, there are some situations where the above code doesnt work - I've updated it with a slightly more robust function:

&lt;code&gt;
def is_numeric?(num)
    true if Float(num) rescue false;
end


my_string = '1';
puts is_numeric?(my_string);&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>@jef</p>
<p>Your right, there are some situations where the above code doesnt work - I&#8217;ve updated it with a slightly more robust function:</p>
<p><code><br />
def is_numeric?(num)<br />
    true if Float(num) rescue false;<br />
end</p>
<p>my_string = '1';<br />
puts is_numeric?(my_string);</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on is_numeric by jef</title>
		<link>http://www.phptoruby.com/is_numeric/comment-page-1#comment-1117</link>
		<dc:creator>jef</dc:creator>
		<pubDate>Sat, 07 Nov 2009 09:06:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.phptoruby.com/is_numeric#comment-1117</guid>
		<description>ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-linux]

&gt;&gt; "1a".is_a?(Numeric)
=&gt; false
&gt;&gt; "1".is_a?(Numeric)
=&gt; false

this info is not correct, do we have to define our own function. please test your code before publishing it!!</description>
		<content:encoded><![CDATA[<p>ruby -v<br />
ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-linux]</p>
<p>&gt;&gt; &#8220;1a&#8221;.is_a?(Numeric)<br />
=&gt; false<br />
&gt;&gt; &#8220;1&#8243;.is_a?(Numeric)<br />
=&gt; false</p>
<p>this info is not correct, do we have to define our own function. please test your code before publishing it!!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
