title: Replace imperative for loop with lambdas
body: <p>I am currently writing a game for fun and I notice I still fall back to the &quot;old&quot; way of looping. Can anyone lend me a hand and show me how this method would look like using lambdas?</p>
  <pre><code>public GameObject findClosestEnemy(Game game, GameObject actor) {
      Double minDistance = null;
      GameObject closestEnemy = null;
  
      for (GameObject o : game.getObjects()) {
          if (isNoEnemy(actor, o)) {
              continue;
          }
  
          double distance = actor.calculateMinEuclideanDistance(o);
          if (minDistance == null || distance &lt; minDistance) {
              minDistance = distance;
              closestEnemy = o;
          }
      }
      return closestEnemy;
  }
  </code></pre>