Jakub Godawa wrote in post #957822:
> There is a abstraction level difference between those methods.

Not in this case.  Rails' methods here are *supplements* to Ruby's 
methods, not abstractions IMHO.

>
> using [].empty? or [].any? would do a Ruby call. It means that you are
> directly asking Ruby interpreter for a answer. That would perform
> better on a bigger scale.
>
> using [].blank? or [].present? (respectively) would do a Ruby call
> through Rails's method. RoR implements it by using the Ruby empty?
> method.
>
> Which of them would be more stable?
> empty? and any? are faster but doesn't work (throw error) with all
> instances of Object class.
> present? is calling the blank? method, and blank? is calling the
> empty? method, but never throws an error (as empty? would do for some
> objects)
>
> # File activesupport/lib/active_support/core_ext/object/blank.rb, line
> 12
>    def blank?
>      respond_to?(:empty?) ? empty? : !self
>    end
>
> I recommand using RoR methods in RoR apps.

Why?  If Rails provides useful magic, use it, but don't use it just 
because it comes from Rails.

(For the record, I love blank?.)

>
> Cheers!
>
> ps. all checked for Rails 3.0.0 and Ruby 1.9.2

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to