Even if List, and Setimplement an interface Iterable, I believe that array, list, set and map - it's all istrebimye objects, because we can use them all through the foreach loop
for(String s : new String[0]);
for(String s : new ArrayList<String>());
for(String s : new HashSet<String>());
for(Entry<Integer, String> entry : new HashMap<Integer, String>().entrySet());
The case with Mapmay be a little different, but consider it as a list of key values (what it really is).
Starting from this iterative understanding, is there a lack of type in the following method?
public boolean isIterable(Object o) {
return o instanceof Object[] || o instanceof Iterable || o instanceof Map;
}
In other words, are there any other types that can be repeated through the foreach loop?
Side, but the resulting question: is the list of exhaustive types?
sp00m source
share