-
-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better syntax for Java array #70
Comments
Suggestion 5) looks most explicit to me for primitive types. For reference types we would have to have a method that accepts |
+1 for point 4 - var arr = JavaArray.create("byte", 10); |
This comment was marked as abuse.
This comment was marked as abuse.
I suggest this syntax to be only for arrays of reference types. Primitive arrays should be covered by the typed arrays support. #65 |
suggest using Array.of syntax similar to this: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of Array.of(android.view.View, 20) we can monkey patch this as this: so it will be actually I think I just implemented it in this comment. That's called "in comment driven development" :) |
We can create globals.js or use our prepareExtends.js to include js functions like this. |
I would be confused to use
it would create JavaScript array |
Consider this as a better variant of Array.fromJavaType. So to take the best of both I suppose Array.ofJavaType is better. The "from" implies an iteratable objects in Javascript |
Also consider this syntax |
I am fine with var a = Array.of(java.lang.Object, 10);
console.log("a.length=" + a.length); it will print |
+1 for |
NativeScript for Android does not provide syntax to create Java array from JavaScript. The current way is quite verbose and not intuitive. For example
There are a few suggestions.
var arr = array([ "element1", "emelemt2", ...]);
This will work for only scenarios where we can deduce the element type.var arr = array("byte", 10)
The first parameter is type name, the second parameter is length.Array
withfromJavaType
or whatever. For examplevar arr = Array.fromJavaType("byte", 10);
var arr = JavaArray.create("byte", 10);
var arr = JavaArray.createByteArray(10);
var arr = new byte(10);
. This scenario does not work for reference types, so should be combined with another one.Any other suggestions are welcome.
Note: suggested syntax that fits TypeScript well have advantage.
The text was updated successfully, but these errors were encountered: