From: Peter Szinek Date: 2007-01-22T18:10:27+09:00 Subject: Re: conditional variable assignment from array Josselin wrote: > one of my methods receives a sort parameter either as > > params => {"sort"=>{"criteria"=>"1"} } > OR > params => {"sort"=>"1"} > > presently, I assign a variable @sc as follows : > > params[:sort].nil? ? @sc = "1" : @sc = params[:sort][:criteria] > > how can I assign @sc to params[:sort][:criteria] OR params[:sort] > whatever received... ? You could try something like stuff = params[:sort] @sc = stuff.is_a? String ? stuff : stuff[:criteria] unless stuff == nil Maybe I did not understand your question properly, if this does not seem to work, please try to elaborate... Peter __ http://www.rubyrailways.com