0

This sentence b.followees_by_type("biscuit") return something like:

=> [#<Biscuit _id: 4fdf5aa11d41c829ea000020, _type: "Biscuit", created_at: 2012-06-18 16:43:13 UTC, title: "biscuit biscuit", is_complete: true>, #<Biscuit _id: 4fdf5aa11d41c829ea000021, _type: "Biscuit", created_at: 2012-06-18 17:40:10 UTC, title: "biscuit2 biscuit2", is_complete: true> ] 

Can return one or more biscuits.

I want add inside a instance variable @biscuits, all biscuits I get in each loop from this block:

boards.each do |b| 
  b.followees_by_type("biscuit")
end

How can I do it?

1
  • 1
    So do it. What's stopping you? Commented Jun 22, 2012 at 17:07

1 Answer 1

1

Use Enumerable#flat_map:

@biscuits = boards.flat_map {|b| b.followees_by_type('biscuit') }
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.