title: Groovy: remove and object from a list within itself?
body: <p>I'm trying to remove objects from a list when it finds that particular objects privacy
  is private to the current user </p>
  
  <pre><code>     books.eachWithIndex{ obj, i -&gt;
  
          if((obj.book.private).equals(true)){
  
            def status = bookService.getBookStatus(obj.book)
  
            if(!status){
                 books.remove(i)
            }
          }
       }
  </code></pre>
  
  <p>error thrown as it tries to remove the object</p>
  
  <p>ERROR errors.GrailsExceptionResolver  - null
  java.util.ConcurrentModificationException</p>
  
  <p>Q: is there any way to remove an object from a list within itself
  or would you have to separately store the index values and remove objects from outside the each loop?</p>