So say I have a Question model and an Answer model and Question has_many Answers (it's a multiple choice question).
Suppose that questions is a collection of Question objects.
In order to collect all the answers I can do this:
questions.collect(&:answers)
Two questions:
What precisely does this syntax mean? Does it expand to
questions.collect { |q| q.answers }
or is there something else going on here?
Is there a way to do
questions.collect { |q| q.answers.shuffle }
using the same syntax?
collect(&:answers.shuffle)
isn't doing it.
I can't seem to find this in tutorials on ruby blocks on the web and searching for it doesn't work (search engines ignore "&:"). I found it in some inherited code.
Thanks