I have what may be a fundamental question to most avid b4a developers but I was wondering if the following code would update the byte array buff1 and if the code is correct. If not for a byte array would it update a basic type such as int or string etc?
sub check
dim buff1() as byte
checkthis (buff1)
msgbox(buff1(1),"Test")
end sub
sub checkthis(buff2() as byte)
buff2(0)=56
buff2(1)=99
end sub
In Java (and therefore B4J and B4A), objects are passed by reference and primitives are passed by value. Arrays are objects, so they are passed by reference, meaning that buff2 in your checkthis sub is a reference to the same array as buff1 in your sub check.
I have what may be a fundamental question to most avid b4a developers but I was wondering if the following code would update the byte array buff1 and if the code is correct. If not for a byte array would it update a basic type such as int or string etc?
sub check
dim buff1() as byte
checkthis (buff1)
msgbox(buff1(1),"Test")
end sub
sub checkthis(buff2() as byte)
buff2(0)=56
buff2(1)=99
end sub