score:3

Accepted answer

I think this should solve you problem

walls.foreach(w => if (curPlayer.intersects(w)) {
  handleCollision
  updateLives(-1)
})

I you want you can also use shorter solution with underscore

walls.foreach(if (curPlayer.intersects(_)) {...})

It wont give you anything but a more concise syntax


Related Query

More Query from same tag