In my opinion, there is too much effort put in making Array behave like a 
normal Java class when it is not. There are already plenty of good options 
in GWT/Java for collections, arrays, etc…
A JavaScript Array is not equivalent to T[], for example this is a 
perfectly fine JavaScript Array [1,2,3,"abc", true, {x:1, y:2}] and cannot 
be modeled in Java. In my opinion, Array should maintain its JavaScript 
nature.

For example if the from method actually returned an Array like it does in 
JavaScript:

public static Array from(JsArrayLike arrayLike);

instead of 

public static final <T, R> R[] from(JsArrayLike<T> arrayLike);

then Colin could write

Array.from(document.querySelectorAll("...")).forEach(element-> ...);

which looks exactly what you would write in JavaScript, and you would not 
have to implement toArray and toList on JsArrayLike, which is not mandated 
by the spec (the only requirement for ArrayLike is an indexed getter and 
the length attribute) Unfortunately,as it is currently, you cannot chain to 
other Array methods when T[] is the return type.

I do understand the desire for asList(), because in JavaScript, I might 
also write

for (elem in document.querySelectorAll(...){
...
}

but implementing Iterable would be a more desirable solution if possible.
​

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit-contributors/0a3d1d8b-2481-474f-8b97-1ed2e7b02421%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to