0

I have a list of items, those items have some attributes one of which is an array list. The array list may be empty or not.

How do i retrieve the items from the list that their array list is not empty

1
  • 1
    Share example data and expected output. Commented Mar 16, 2016 at 18:13

1 Answer 1

1

You can use select together with present? (or reject/blank?):

items = items.select{|x| x.array_attribute.present?}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.