Quick question here — I just used JsArrayString for the first time, and was surprised that this didn’t work:
JsArrayString object = ...;
for (String s : object)
So I just wrote a C-style for loop:
JsArrayString object = ...;
for (int i=0; i<object.length(); i++) {
s = object.get(i)
...
Not a big deal, but seems like it would have been simple for the GWT team to have JSArrayString implement iterable, so I wanted to check and make sure I wasn’t missing something…
I suspect it’s a matter of code bloat and for that matter code size. If they make
JsArrayimplementIterable, it might open the door for other additions that wouldn’t always be useful.JsArrays are meant to be absolutely as simple and barebones as possible.Additionally, you could write your own
JsIterableclass that does this if you want this behavior, as you said it should be pretty trivial to implement.The Lightweight Collections design doc addresses some of the issues around using JRE collections and related concepts and discusses which features could be left unsupported to ensure absolute minimum code size, including: