Thursday, December 27, 2007

If, Else, and Elsif Constructs

Too many if else statements can create confusion for ruby developers. If so better to refactor the code. Ruby is such an amazing object oriented language that this procedural garbage is the quickest way to ugly, unreadable code.

if you ever write something like this:
1
2
3
if my_object!= my_object_not
if my_object!= nil

If you wanna take the advantage of ruby use the following code for better readability

unless my_object== my_object_else
unless my_object.nil?

No comments: