From: Devin Mullins Date: 2007-02-08T22:45:31+09:00 Subject: Re: DRY or not ... Josselin wrote: > if params[:new_title].blank? > params[:new_title] = nil > elsif params[:new_title] == "null" > params[:new_title] = "" > end params[:new_title] = if params[:new_title].blank? nil elsif params[:new_title] == "null" "" end For reasons yet unbeknownst to you, reverse that if statement: params[:new_title] = if params[:new_title] == "null" "" elsif params[:new_title].blank? nil end Implicit in that if statement is an "else nil". (Try it in IRB.) So you don't really need anything but the first part: params[:new_title] = if params[:new_title] == "null" "" end You can shorten even further by using the line-modifier version: params[:new_title] = ("" if params[:new_title] == "null") (Parentheses are important, here. Otherwise, the if modifies the whole line, and if not "null", the :new_title remains unchanged.) But that's a little greek. Here's another way: params[:new_title] = params[:new_title] == 'null' ? '' : nil Now, there's something very weird with the above logic, in the first place. You might be able to reduce even more code by changing the thing that sets :new_title. ("null", for Ford's sake?) Devin