B4J Question I'm wrong

Gianni M

Well-Known Member
Licensed User
Longtime User
I'm wrong !! ??
the code module returns the list and map values, not the string. Why? I'm confused?
 

Attachments

String values are passed By Value, List and Map are passed By Reference (just like objects)

You should change the signature of the subroutine and return the Gamma string. Like this:

B4X: Copy
Public Sub subRoutine1 (alfa As List, beta As Map) As String
    alfa.Initialize
    beta.Initialize
    '
    alfa.AddAll(Array As String("One", "Two", "Three", "Four", "Five"))
    '
    beta.Put("ciao", "Hello")
    beta.Put("mondo", "World")
    '
    Return "why doesn't the value return?"
End Sub

And then call the subroutine in your maincode this way:

B4X: Copy
gamma = demo.subRoutine1 (list1, map1)
Log(gamma)
 
Upvote 0
Upvote 0
Back
Top