Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function passByValue(value)
- value = "no"
- end
- local example = "hello"
- passByValue(example)
- print(example) -- what get's printed?
- local function passByReference(reference)
- reference[1]= "no"
- end
- local example2 = {"hello"}
- passByReference(example2)
- print(example2[1]) -- what get's printed?
- -- In lua tables, functions, and coroutines are passed by reference. This is unlike every other type in lua.
Advertisement
Add Comment
Please, Sign In to add comment