How to check if all objects are present?

Asked

Viewed 37 times

0

Is there a method in ruby that checks whether all objects are present? It would be something to avoid the following use:

if @stretch_source.present? && stretch_target.present?

Or would this really be the right way?

1 answer

1

I was going to put that in comment but I don’t have enough rep.

You want to check if all the objects are present where? You can check in an array.

[@stretch_source, stretch_target].all?(&:present?)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.