<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>rors.org</title>
    <link>http://rors.org</link>
    <description>rors.org - Blog posts</description>
    <language>en</language>
    <item>
      <title>10 Rails console tricks</title>
      <description>&lt;h2&gt;Invoking helper methods&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt; helper.number_to_currency('123.45')
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Method definition finder (irb)&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt; helper.method(:truncate)
=&amp;gt; #&amp;lt;Method: ActionView::Base(ActionView::Helpers::TextHelper)#truncate&amp;gt;

&amp;gt;&amp;gt; "".method(:camelize)
=&amp;gt; #&amp;lt;Method: String(ActiveSupport::CoreExtensions::String::Inflections)#camelize&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Method finder (irb)&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;$ gem install what_methods

&amp;gt;&amp;gt; require 'what_methods'
&amp;gt;&amp;gt; "foo ".what? "foo"
"foo ".chop! == "foo"
"foo ".chop == "foo"
"foo ".strip! == "foo"
"foo ".strip == "foo"
"foo ".rstrip! == "foo"
"foo ".rstrip == "foo"
=&amp;gt; ["chop!", "chop", "strip!", "strip", "rstrip!", "rstrip"]
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Method lookup (irb)&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt; "".methods.grep(/case/).sort
=&amp;gt; ["camelcase", "casecmp", "downcase", "downcase!", "swapcase", "swapcase!", "titlecase", "upcase", "upcase!"]
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Avoid screenfuls of objects (irb)&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt; people = Person.all; nil
=&amp;gt; nil
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Rollback database modifications on exit&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;$ ./script/console --sandbox
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Last expression (irb)&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt; Person.first
=&amp;gt; #&amp;lt;Person id: 1, first_name: "Dejan" ... &amp;gt;
&amp;gt;&amp;gt; _.first_name
=&amp;gt; "Dejan"
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Reload code changes&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt; reload!
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Better object format (irb)&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt; y User.first
--- !ruby/object:User 
attributes: 
  hashed_password: 123456789cde83xa9b86e36e4627360
  last_seen_at: 2009-12-09 13:16:44
  username: dejan
  id: "1"
  created_at: 2007-01-14 17:30:00
attributes_cache: {}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;script/console logging&lt;/h2&gt;
&lt;p&gt;You need &lt;a href="http://toolmantim.com/articles/system_wide_script_console_logging"&gt;this&lt;/a&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt; User.cached(:first)
==&amp;gt; Got User:first from cache. (0.10173)
  User Load (300.1ms)   SELECT * FROM `users` LIMIT 1
==&amp;gt; Set User:first to cache. (0.01512)
=&amp;gt; #&amp;lt;User id: 1, username: "dejan", ... &amp;gt;

&amp;gt;&amp;gt; User.cached(:first)
==&amp;gt; Got User:first from cache. (0.00061)
=&amp;gt; #&amp;lt;User id: 1, username: "dejan", ... &amp;gt;

&amp;gt;&amp;gt; User.expire_cache(:first)
==&amp;gt; Deleted User:first from cache. (0.00059)
=&amp;gt; true
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;&lt;span class="caps"&gt;LINKS&lt;/span&gt;&lt;/h2&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;a href="http://stackoverflow.com/questions/123494/whats-your-favourite-irb-trick"&gt;http://stackoverflow.com/questions/123494/whats-your-favourite-irb-trick&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="http://slash7.com/2006/12/21/secrets-of-the-rails-console-ninjas/"&gt;http://slash7.com/2006/12/21/secrets-of-the-rails-console-ninjas/&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="http://toolmantim.com/articles/system_wide_script_console_logging"&gt;http://toolmantim.com/articles/system_wide_script_console_logging&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="http://drnicwilliams.com/2006/10/12/my-irbrc-for-consoleirb/"&gt;http://drnicwilliams.com/2006/10/12/my-irbrc-for-consoleirb/&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="http://railscasts.com/episodes/48-console-tricks"&gt;http://railscasts.com/episodes/48-console-tricks&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="http://pablotron.org/software/wirble/"&gt;http://pablotron.org/software/wirble/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
      <pubDate>Sun, 20 Dec 2009 00:00:00 +0000</pubDate>
      <author>Dejan Simic</author>
      <link>http://rors.org/2009/12/20/10-rails-console-tricks</link>
      <guid>http://rors.org/2009/12/20/10-rails-console-tricks</guid>
    </item>
    <item>
      <title>Editing /etc/hosts on Mac OS</title>
      <description>&lt;p&gt;I almost killed my macbook until I figured this out. In Linux there&amp;#8217;s no need for this, but on Mac OS, after editing /etc/hosts in order to immediately apply changes you must run this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;lookupd -flushcache
&lt;/code&gt;&lt;/pre&gt;</description>
      <pubDate>Tue, 24 Mar 2009 00:00:00 +0000</pubDate>
      <author>Dejan Simic</author>
      <link>http://rors.org/2009/3/24/editing-etc-hosts-on-mac-os</link>
      <guid>http://rors.org/2009/3/24/editing-etc-hosts-on-mac-os</guid>
    </item>
    <item>
      <title>Accountability</title>
      <description>&lt;p&gt;&lt;em&gt;&lt;br /&gt;&amp;#8220;I heard once that in Great Britain&amp;#8217;s &lt;span class="caps"&gt;MOD&lt;/span&gt; if you design software for a plane you go up in the test plane when the software is beta-tested. If all programmers were held with that level of accountability, how many do you think would still be in our field? How many would you want to collaborate with before you went up in the plane together?&amp;#8221; &lt;br /&gt;&lt;/em&gt;&lt;br /&gt;
&amp;#8212;&lt;a href="http://blog.jayfields.com/2009/01/cost-of-net-negative-producing.html"&gt;http://blog.jayfields.com/2009/01/cost-of-net-n&amp;#8230;&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Sun, 15 Feb 2009 00:00:00 +0000</pubDate>
      <author>Dejan Simic</author>
      <link>http://rors.org/2009/2/15/accountability</link>
      <guid>http://rors.org/2009/2/15/accountability</guid>
    </item>
    <item>
      <title>auto_html plugin</title>
      <description>&lt;p&gt;Read more about my new Rails plugin on company&amp;#8217;s blog:&lt;br /&gt;&lt;a href="http://www.elctech.com/projects/auto_html-plugin"&gt;http://www.elctech.com/projects/auto_html-plugin&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Fri, 13 Feb 2009 00:00:00 +0000</pubDate>
      <author>Dejan Simic</author>
      <link>http://rors.org/2009/2/13/auto_html-plugin</link>
      <guid>http://rors.org/2009/2/13/auto_html-plugin</guid>
    </item>
    <item>
      <title>Random Haml tips</title>
      <description>&lt;p&gt;I&amp;#8217;ve just shared my love to Haml on company&amp;#8217;s blog: &lt;br /&gt;&lt;a href="http://www.elctech.com/articles/random-haml-tips"&gt;http://www.elctech.com/articles/random-haml-tips&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Sat, 31 Jan 2009 00:00:00 +0000</pubDate>
      <author>Dejan Simic</author>
      <link>http://rors.org/2009/1/31/random-haml-tips</link>
      <guid>http://rors.org/2009/1/31/random-haml-tips</guid>
    </item>
    <item>
      <title>My pet is growing</title>
      <description>On this day, exactly two years ago I&amp;#8217;ve deployed the first public release of something that is best described as &amp;#8220;&lt;a href="http://urbandictionary.com"&gt;urbandictionary.com&lt;/a&gt; in Serbian&amp;#8221;. &lt;br /&gt;
Some interesting facts:&lt;br /&gt;
	&lt;ul&gt;
	&lt;li&gt;&lt;a href="http://vukajlija.com"&gt;vukajlija.com&lt;/a&gt; is inspired by urbandictionary.com and built on Rails. I&amp;#8217;ve recently found out that urbandictionary.com switched from &lt;span class="caps"&gt;PHP&lt;/span&gt; to Rails.&lt;br /&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://vukajlija.com"&gt;vukajlija.com&lt;/a&gt; is still just my pet project. I&amp;#8217;m not earning any money from it, but it pays its own bills. I&amp;#8217;m working on it when I find free time for fun and to gain more experience with Ruby and Rails.&lt;br /&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://vukajlija.com"&gt;vukajlija.com&lt;/a&gt; has a constant growth in visits and pageviews for the past 16 months.&lt;br /&gt;
&lt;br/&gt;&lt;br /&gt;
&lt;img src="http://img.skitch.com/20090114-dc6xqmfkbg64tra1g28aktq6yi.png" alt="" /&gt;&lt;br /&gt;
&lt;br/&gt;&lt;br /&gt;&lt;img src="http://img.skitch.com/20090114-rr6b61q4q7usx2scgu3bwwrgab.png" alt="" /&gt;&lt;/li&gt;
	&lt;/ul&gt;</description>
      <pubDate>Wed, 14 Jan 2009 00:00:00 +0000</pubDate>
      <author>Dejan Simic</author>
      <link>http://rors.org/2009/1/14/my-pet-is-growing</link>
      <guid>http://rors.org/2009/1/14/my-pet-is-growing</guid>
    </item>
    <item>
      <title>Rails SEO Starter Guide</title>
      <description>&lt;p&gt;I&amp;#8217;ve just posted &lt;a href="http://www.elctech.com/projects/rails-seo-starter-guide"&gt;Rails &lt;span class="caps"&gt;SEO&lt;/span&gt; Starter Guide&lt;/a&gt; on company&amp;#8217;s blog. Go check it out.&lt;/p&gt;</description>
      <pubDate>Wed, 19 Nov 2008 00:00:00 +0000</pubDate>
      <author>Dejan Simic</author>
      <link>http://rors.org/2008/11/19/rails-seo-starter-guide</link>
      <guid>http://rors.org/2008/11/19/rails-seo-starter-guide</guid>
    </item>
    <item>
      <title>simple_captcha while developing</title>
      <description>&lt;p&gt;&lt;em&gt;Type less&lt;/em&gt; is my motto these days. Not just the code, but everything.&lt;/p&gt;
&lt;p&gt;If you&amp;#8217;re developing an app with the excellent &lt;a href="http://expressica.com/simple_captcha/"&gt;simple_captcha plugin&lt;/a&gt; do your fingers a favor and monkey patch it in development.rb:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# type less. autosolve captcha while developing
ActionView::Base.module_eval do
  def simple_captcha_field(options={})
    options[:object] ?
      text_field(options[:object], :captcha, :value =&amp;gt; simple_captcha_value(simple_captcha_key)) +
        hidden_field(options[:object], :captcha_key, {:value =&amp;gt; options[:field_value]}) : 
      text_field_tag(:captcha, simple_captcha_value(simple_captcha_key))
  end
end
&lt;/code&gt;&lt;/pre&gt;</description>
      <pubDate>Wed, 29 Oct 2008 00:00:00 +0000</pubDate>
      <author>Dejan Simic</author>
      <link>http://rors.org/2008/10/29/simple_captcha-while-developing</link>
      <guid>http://rors.org/2008/10/29/simple_captcha-while-developing</guid>
    </item>
    <item>
      <title>Don't escape in Strings</title>
      <description>&lt;p&gt;So don&amp;#8217;t do:&lt;/p&gt;
&lt;pre class="bad-code"&gt;&lt;code&gt;"#{name} said: \"Clap your hands!\""
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It&amp;#8217;s ugly and you don&amp;#8217;t need it. Ruby has excellent support for arbitrary delimiters for string literals.&lt;/p&gt;
&lt;p&gt;So above can be rewritten as:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;%-#{@name} says: "Clap your hands!"-
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&amp;#8230; or if String contains dash:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;%/#{@name} says: "Play tic-tac-toe!"/
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&amp;#8230; or if String contains dash and slash:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
%Q|#{@name} says: "Try ftp://ruby-lang.org/pub/ruby/1.9/"|
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&amp;#8230; and so on. No need to escape.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Excerpt from the great book &lt;a href="http://www.amazon.com/Ruby-Programming-Language-David-Flanagan/dp/0596516177"&gt;The Ruby programming Language&lt;/a&gt;:&lt;br /&gt;
&lt;em&gt;&lt;br /&gt;
&amp;#8220;The sequence %q begins a string literal that follows single-quoted string rules, and the sequence %Q (or just %) introduces a literal that follows double-qouted string rules. The first character following q or Q is the delimiter, and the string literal continues until a matching delimiter is found. If the opening delimiter is (, [, {, or &amp;lt;, then the matching delimiter is ), ], }, or &amp;gt;. Otherwise, the closing delimiter is the same as the opening delimiter.&amp;#8221;&lt;br /&gt;
&lt;/em&gt;&lt;/p&gt;</description>
      <pubDate>Sun, 26 Oct 2008 00:00:00 +0000</pubDate>
      <author>Dejan Simic</author>
      <link>http://rors.org/2008/10/26/dont-escape-in-strings</link>
      <guid>http://rors.org/2008/10/26/dont-escape-in-strings</guid>
    </item>
    <item>
      <title>So create</title>
      <description>&lt;p&gt;&lt;a href="http://twitter.com/_why/statuses/881768089"&gt;&lt;img src="http://twictur.es/i/881768089.gif" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Fri, 29 Aug 2008 00:00:00 +0000</pubDate>
      <author>Dejan Simic</author>
      <link>http://rors.org/2008/8/29/so-create</link>
      <guid>http://rors.org/2008/8/29/so-create</guid>
    </item>
    <item>
      <title>Alternatives</title>
      <description>&lt;p&gt;A year ago, I got interested in alternatives, and started switching:&lt;/p&gt;


	&lt;p&gt;&lt;del&gt;erb&lt;/del&gt;  =&amp;gt; haml &lt;br /&gt;&lt;del&gt;test_unit&lt;/del&gt; =&amp;gt; rspec&lt;br /&gt;&lt;del&gt;prototype/scriptaculous&lt;/del&gt; =&amp;gt;  jQuery&lt;br /&gt;...&lt;/p&gt;


	&lt;p&gt;&lt;em&gt;mental note to myself: &lt;strong&gt;stay the hell away from merb!&lt;/strong&gt; ;)&lt;/em&gt;&lt;/p&gt;</description>
      <pubDate>Mon, 18 Aug 2008 00:00:00 +0000</pubDate>
      <author>Dejan Simic</author>
      <link>http://rors.org/2008/8/18/alternatives</link>
      <guid>http://rors.org/2008/8/18/alternatives</guid>
    </item>
    <item>
      <title>Alternative join and split in Ruby</title>
      <description>&lt;p&gt;&lt;strong&gt;Join&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt; %w(tic tac toe) * "-" 
=&amp;gt; "tic-tac-toe"
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Split&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt; "tic-tac-toe" / "-" 
=&amp;gt; ["tic", "tac", "toe"]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Unfortunately, for &lt;em&gt;split&lt;/em&gt; you&amp;#8217;ll need this of course:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;class String
  alias / :split
end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;;)&lt;/p&gt;</description>
      <pubDate>Wed, 09 Jul 2008 00:00:00 +0000</pubDate>
      <author>Dejan Simic</author>
      <link>http://rors.org/2008/7/09/alternative-join-and-split-in-ruby</link>
      <guid>http://rors.org/2008/7/09/alternative-join-and-split-in-ruby</guid>
    </item>
    <item>
      <title>Self or default if empty, DRY way</title>
      <description>&lt;p&gt;I really appreciate following idiom in Ruby:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;person.phone || "N/A"
&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;It&amp;#8217;s &lt;span class="caps"&gt;DRY&lt;/span&gt;. No need for conditional structures, and repeating person.phone in condition and as return value.&lt;/p&gt;
&lt;p&gt;But lets say you don&amp;#8217;t control your data source, and there is an empty string instead of nil when data is not available (sounds familiar?). How would you deal with that and keep things simple and &lt;span class="caps"&gt;DRY&lt;/span&gt;?&lt;/p&gt;
&lt;p&gt;Well, basicly all you need is a String method that will return nil if string is empty, or self if it&amp;#8217;s not empty. String object doesn&amp;#8217;t have that kind of method, at least not that specialized. Regexp to rescue. Lets try this:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt; ""[/.+/m]
=&amp;gt; nil&lt;/p&gt;
&lt;p&gt;&amp;gt;&amp;gt; &amp;#8220;ruby&amp;#8221;[/.+/m]&lt;br /&gt;
=&amp;gt; &amp;#8220;ruby&amp;#8221;&lt;br /&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Nice. So solution for the problem above is:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;person.phone[/.+/m] || "N/A"
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Throw &lt;a href="http://rors.org/2008/3/18/andand"&gt;andand&lt;/a&gt; in game to support both nil and empty value with no cost in complexity:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;person.phone.andand[/.+/m] || "N/A"
&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;</description>
      <pubDate>Wed, 19 Mar 2008 00:00:00 +0000</pubDate>
      <author>Dejan Simic</author>
      <link>http://rors.org/2008/3/19/self-or-default-if-empty-dry-way</link>
      <guid>http://rors.org/2008/3/19/self-or-default-if-empty-dry-way</guid>
    </item>
    <item>
      <title>andand</title>
      <description>&lt;p&gt;I really, really like &lt;a href="http://andand.rubyforge.org/"&gt;andand&lt;/a&gt; . Try it and stop repeating yourself.&lt;/p&gt;
&lt;p&gt;I mean, why would you want to write this:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;entry.at('description') &amp;amp;&amp;amp; entry.at('description').inner_text
&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;when you can write this:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;entry.at('description').andand.inner_text
&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;</description>
      <pubDate>Tue, 18 Mar 2008 00:00:00 +0000</pubDate>
      <author>Dejan Simic</author>
      <link>http://rors.org/2008/3/18/andand</link>
      <guid>http://rors.org/2008/3/18/andand</guid>
    </item>
    <item>
      <title>Eleventh</title>
      <description>&lt;p&gt;Did you know that Ruby was Matz&amp;#8217; eleventh take on creating a programming language?   &lt;a href="http://podcast.rubyonrails.org/system/audio/2006/rails-040-Yukihiro_Matz_Matsumoto.mp3"&gt;Listen&lt;/a&gt;. So don&amp;#8217;t despare next time you fail, you are right on track.&lt;/p&gt;
&lt;p&gt;&amp;#8220;I sat down and counted the other day and Ruby was eleventh language I&amp;#8217;ve tried to write. Out of those 4 only had names, 3 of them didn&amp;#8217;t work at all&amp;#8230; the rest of them was just experiments. Ruby is the only one that really worked, so I guess that makes Ruby the first one, but it was one out of eleven attempts.&amp;#8221; ~ Matz&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;The road to wisdom? -- Well, it's plain
and simple to express:
           Err
           and err
           and err again
           but less
           and less
           and less.

~Piet Hein
&lt;/code&gt;&lt;/pre&gt;</description>
      <pubDate>Mon, 11 Feb 2008 00:00:00 +0000</pubDate>
      <author>Dejan Simic</author>
      <link>http://rors.org/2008/2/11/eleventh</link>
      <guid>http://rors.org/2008/2/11/eleventh</guid>
    </item>
    <item>
      <title>Nested Ternary operator</title>
      <description>&lt;p&gt;I was going through some of my old Java code and found this interesting piece of code. It&amp;#8217;s basically alternative way of creating switch structure.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;public Object getValueAt(int row, int col) {
  Person person = data.get(row);
  return 
    col==0? person.getFirstName() 
    : col==1? person.getLastName() 
    : col==2? person.getAge()            
    : col==3? person.getAddress()
    : null; 
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Cons:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;unlike switch, there is no compile time error for duplicated cases&lt;/li&gt;
	&lt;li&gt;this is not a standard way of dealing with different values of a variable so you could leave wondering the person that will read your code&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Pros:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;more control over branching logic since expressions are used (switch must use constants as case values)&lt;/li&gt;
	&lt;li&gt;this is not a standard way of dealing with different values of a variable so you could be seen as hacker in the eyes of the person that will read your code ;)&lt;/li&gt;
&lt;/ul&gt;</description>
      <pubDate>Sun, 20 Jan 2008 00:00:00 +0000</pubDate>
      <author>Dejan Simic</author>
      <link>http://rors.org/2008/1/20/nested-ternary-operator</link>
      <guid>http://rors.org/2008/1/20/nested-ternary-operator</guid>
    </item>
  </channel>
</rss>
