Skip to main content

All Questions

0 votes
3 answers
30 views

PHP iterating through array - Can't reach top level values?

I try to search long and hard to find my answers and almost never ask questions if I can help it. but it's 5am and I've been working on this project for quite a few months now and I'm stuck. THE ...
Jeremy Womack's user avatar
2 votes
1 answer
2k views

Java foreach NoSuchElementException

The other days we found a rather awkward exception in the logs of our application in this piece of code: final LIST currentSinks = this.sinks; if (null != currentSinks && !currentSinks....
Olimpiu POP's user avatar
  • 5,077
161 votes
13 answers
97k views

Is if(items != null) superfluous before foreach(T item in items)?

I often come across code like the following: if ( items != null) { foreach(T item in items) { //... } } Basically, the if condition ensures that foreach block will execute only if ...
Sarfaraz Nawaz's user avatar
6 votes
2 answers
6k views

Java for each, but multiple iterator types?

I have a class Polygon on which I wish to implement two iterators: one to run through all elements (vertices and edges in alternating order) just ONCE, and another to run through them ad infinitum (...
Engineer's user avatar
  • 8,873