No one likes the classes.
I understand that in some cases it's easier to use a Map (I love the Maps) or an array, but... there is little talk of classes, in this site.
Yet, "severl values", often means a precise object.
(A little bit off topic, I know; but at least I'll add a post in which you talk about classes )
No one likes the classes.
I understand that in some cases it's easier to use a Map (I love the Maps) or an array, but... there is little talk of classes, in this site.
Yet, "severl values", often means a precise object.
(A little bit off topic, I know; but at least I'll add a post in which you talk about classes )
Looks possible in a single activity though where different instances of the same class can be passed as parameters to a sub. From a quick timing check it looks like it is by reference.
In Test 1 I pass an object of type AHLocale from Main to SecondActivity through a CallSubDelayed2; I get this error: java.lang.Exception: Sub setlocale signature does not match expected signature.
In Test 2 I try to pass an object created from a my class and I get a different error: java.lang.ClassCastException: java.lang.Object[] cannot be cast to b4a.example.myclass
However, this is an absurd limitation, never seen in other languages.
Classes in B4A, at this point, do not work as they should.
Yes, that's was the error in Test 1, but my comments about "other languages" concerns classes/objects.
In fact, I do not get errors now from test 1, passing an object to the routine of SecondActivity (Local object), but I can not pass an object created from my class.
B4X:
Public Sub SetMyClassObject(MyClassObject As Object) ' <--- this does not work
'Public Sub SetMyClassObject(MyClassObject As MyClass) ' <--- this does not work
Dim MyObject As MyClass = MyClassObject
Log(MyObject.Name)
End Sub
Public Sub SetLocale(Loc As AHLocale) ' <--- this works, Loc is an object
Log(Loc.Country)
End Sub
I had already fixed the error (array) in the project attached in #12.
But neither of these declarations work:
B4X:
Public Sub SetMyClassObject(MyClassObject As Object) ' <--- this does not work
'Public Sub SetMyClassObject(MyClassObject As MyClass) ' <--- this does not work
Dim MyObject As MyClass = MyClassObject
Log(MyObject.Name)
End Sub