From: ChrisH Date: 2006-08-28T22:30:11+09:00 Subject: Re: Newbie : assign a value to a variable... Nicolas Blanco wrote: ... > if @params[:per_page].nil? > per_page = 20 > else > per_page = @params[:per_page] > end > > Is there a better way to do this (put the parameter in the variable if > the parameter is not null, otherwise put 20) ? The usual idiom is per_page = @params[:per_page] || 20 cheers