The opposite of Rails blank? is present?

params[:id].present?
nil.present?

( the original post was a hack adding String.filled? / NilClass.filled? )

6 thoughts on “The opposite of Rails blank? is present?

  1. Why not using “any?”.

    Sure, you’d have to add the definition to NilClass, but it makes sense.
    For Strings, Arrays and Hashes, however, it is already defined.

  2. never thought that any? is defined for String, its a good alternative to filled? (especially if you do not want to hack String), but I still prefer params[:name].filled? over params[:name].any? out of pure readability

Leave a comment