And instead of empty, you should use "blank?", that would work even if
@results is "nil"

x = @results.blank? ? 1 : 0

-
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en)



On Tue, Jan 13, 2009 at 6:05 PM, Pardee, Roy <parde...@ghc.org> wrote:
>
> x = @results.empty? ? 1 : 0
>
> -----Original Message-----
> From: rubyonrails-talk@googlegroups.com 
> [mailto:rubyonrails-t...@googlegroups.com] On Behalf Of James Bond
> Sent: Tuesday, January 13, 2009 11:42 AM
> To: rubyonrails-talk@googlegroups.com
> Subject: [Rails] Re: Number of entries
>
>
> How can I write it simple?
>
> if @results.empty?
> x = 0
> else
> x = 1
> end
> --
> Posted via http://www.ruby-forum.com/.
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to