Question about populating the "particles" Array

I don’t quite follow how the particles array is getting populated or I guess how the addParticle() func is getting called multiple times. I know it is cause the program runs just like the book says it should.

Hi Mark,

The particles array is populated by calling simulation.addParticle(ball). The addParticle(:slight_smile: method then calls append(:slight_smile: on the particles array. Only one particle is added in the book.

Does that help?


Yes it does. Thanks, after looking at the code a while it began to make sense.