<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>ronin: Ruby error checking</title>
    <link>http://blogs.divisibleprime.com/ronin/articles/2006/08/20/ruby-error-checking</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Stuff</description>
    <item>
      <title>Ruby error checking</title>
      <description>&lt;p&gt;&lt;a href="http://www.tbray.org/ongoing/"&gt;Tim Bray&lt;/a&gt; is running a &lt;a href="http://www.tbray.org/ongoing/When/200x/2006/08/17/JRuby"&gt;series&lt;/a&gt; of posts on an Atom Publishing Protocol client that tests out an APP implementation called &lt;a href="http://www.tbray.org/ape/"&gt;APE&lt;/a&gt;, or Atom Protocol Exerciser.&lt;/p&gt;

&lt;p&gt;In one of the series Tim describes how he uses Duck Typing to handle checking a URI for validity.  My first thought was: That isn&amp;#8217;t an example of Duck Typing.  &lt;a href="http://www.intertwingly.net/blog/2006/08/19/Quack-Squared"&gt;Sam Ruby&lt;/a&gt; has posted his thoughts on how it should be done, which is Ok, but I think I have something equally as good.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;def some_method
    return [true, "actual return value here"]
end

ok, value = some_method
return "this didn't work" unless ok
puts value
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This way, you never need to check whether something is of a certain Type, and it doesn&amp;#8217;t impact the readability much either.  Some people might not like the Array return type however, each to his own.&lt;/p&gt;

&lt;p&gt;This is how the xmlrpc library works when using the client.call2 api.&lt;/p&gt;</description>
      <pubDate>Sun, 20 Aug 2006 10:19:00 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:7a1b533e-7975-423e-a6bb-bda574b3f2de</guid>
      <author>Kerry</author>
      <link>http://blogs.divisibleprime.com/ronin/articles/2006/08/20/ruby-error-checking</link>
      <category>Tech</category>
      <category>Syndication</category>
      <category>Ruby</category>
    </item>
  </channel>
</rss>
