Private hidden() As String = Array As String("one", "two", "three")
Private shown() As String = Array As String("four", "five", "six")
Private all() As String = Array As String(hidden(), shown())
But the above does not work.
Or is the only option to merge them in a function at init?
@alwaysbusy can yo take a look at this?
Kind of not so much fun to change it manually every time I build.
The transpiler should make this code to make it work:
JavaScript:
this.all = this.arr1.concat(this.arr2);
Instead of the wrong one I mention in previous reply with _B.arr2.
I need a runnable example to find out what goes wrong in your code. Works fine here:
B4X:
Sub BANano_Ready()
Dim arr1() As String = Array(1,2,3)
Dim arr2() As String = Array(4,5,6)
Dim all() As String = BANano.Concat(arr1, arr2)
Log(all) ' [1,2,3,4,5,6]
End Sub
The only way I can reproduce something like yours is because you would put all of it in the Globals method, which is just for declaration in B4J.
B4X:
Sub Process_Globals
Dim arr1() As String = Array(1,2,3)
Dim arr2() As String = Array(4,5,6)
Dim all() As String = BANano.Concat(arr1, arr2)
End Sub
But this is would be wrong as the IDE even shows in the logs:
Main - 14: This sub should only be used for variables declaration or assignments of primitive values. (warning #29)
I need a runnable example to find out what goes wrong in your code. Works fine here:
B4X:
Sub BANano_Ready()
Dim arr1() As String = Array(1,2,3)
Dim arr2() As String = Array(4,5,6)
Dim all() As String = BANano.Concat(arr1, arr2)
Log(all) ' [1,2,3,4,5,6]
End Sub
The only way I can reproduce something like yours is because you would put all of it in the Globals method, which is just for declaration in B4J.
B4X:
Sub Process_Globals
Dim arr1() As String = Array(1,2,3)
Dim arr2() As String = Array(4,5,6)
Dim all() As String = BANano.Concat(arr1, arr2)
End Sub
But this is would be wrong as the IDE even shows in the logs:
Main - 14: This sub should only be used for variables declaration or assignments of primitive values. (warning #29)
Ok, then it is my fault. I missed that warning.
I have it in the Process_Globals but it works if it has "this" instead of _B and if I look in Javascript descriptions then I do not find that limitation.
But what I want to do is have two separate arrays concatenated to one, see first question in this thread.
I need to use the two arrays separately and them both together and concat works as I want but maybe you have a better solution?
True, but it is a B4J one. I honestly don't see the problem why you can not just concat them in the initialize of the class (or write one if it is a module and run it in BANano_Ready). Beats having to that manual change every time you do a build to me. As in B4J, BANano uses Global only for declarations and primitive initializations. There are many things that can be done in JavaScript and not in B4J, but we've chosen to get as close as possible to B4X behavior as possible.
True, but it is a B4J one. I honestly don't see the problem why you can not just concat them in the initialize of the class (or write one if it is a module and run it in BANano_Ready). Beats having to that manual change every time you do a build to me. As in B4J, BANano uses Global only for declarations and primitive initializations. There are many things that can be done in JavaScript and not in B4J, but we've chosen to get as close as possible to B4X behavior as possible.