B4J Question Null parameters.

LucaMs

Expert
Licensed User
Longtime User
My question is written as comment line.

B4X:
    Type tTest(Elems As List)
    Private objTest As tTest

    objTest = CreatetTest(Null)

B4X:
Public Sub CreatetTest (Elems As List) As tTest
    Dim t1 As tTest
    t1.Initialize

'    If Elems = Null Then ' Why Elems is not Null here and I have to use the next line?
    If Elems.IsInitialized = False Then
        Elems.Initialize
    End If
    t1.Elems = Elems
    Return t1
End Sub

More than a question it is a fact, but it doesn't seem very correct to me.



Note (for the picky ones like me ?): obviously I would never create a custom type like that, with only one "field".
 
Last edited:

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
List and Maps are difficult to handle on Java. to treat them as a the core lib do, You have to create an object and a b4x list separetely and wrap the object inside the list.
Thats why you have to call isInitialized. i am pretty sure that no other classes or types has that problem (Strings and nulls are also complicated)
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
https://softwareengineering.stackex... null by default,error when they are accessed.


 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…