On Aug 28, 2006, at 8:30 AM, Harold Hausman wrote:

>>
>> You can use the || (or) operator:
>>
>>    per_page = @params[:per_page] || 20
>>
>>
>> David
>>
>
> I think you've got to be careful about your precedence there...
>
> irb(main):001:0> foo = nil or 20
> => 20
> irb(main):002:0> foo
> => nil
> irb(main):003:0> foo = (nil or 20)
> => 20
> irb(main):004:0> foo
> => 20
>
> Though, maybe it's just irb?

IRb and Ruby treat this the same, but David didn't use "or" so the  
precedence is fine.  ;)

James Edward Gray II