#&
1 messages · Page 1 of 1 (latest)
ye in older languages
however newer languages don't support ByRef parameters
you can just return the value of p, and set the var to that value
local function func(p)
p.value += 1
return p
end
local var = {value = 0}
var = func(var)
print(var.value)
that's ugly 😔
you don't need the var=func(var)
all tables pass by reference
local function func(p)
p.value += 1
end
local var = {value = 0}
func(var)
print(var.value)```
Requested by: @vernal roost```ansi
1
Compilation completed | 1.0820961630088277
wtf is func()
to answer your question more directly, you're already doing the reference trick. that's the only way.
all other base types get passed by value / copy
only things passed by reference I am aware of is tables, and userdata like instances (which are effectively just tables)
there's another way but it uses metatables and it looks more ugly
that's still a table being passed by reference
I mean it uses the meta features