Take the "do" out of the statement when passing a block in {}:
collection_of_objects = []
10.times {collection_of_objects << MyObject.create}
:)
On 9/28/07 2:13 AM, "Daniel Talsky" <danieltalsky@gmail.com> wrote:
> How come this works:
>
> collection_of_objects = []
> 10.times do
> collection_of_objects << MyObject.create
> end
>
> But this doesn't:
>
> collection_of_objects = []
> 10.times do { collection_of_objects << MyObject.create }
>
> I didn't understand there was ANY difference between the two syntaxes
> really. Can someone explain to me the finer points?