8000 Immutability of table parameters in question · Issue #548 · NLua/NLua · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Immutability of table parameters in question #548
Open
@phillk6751

Description

@phillk6751

When attempting to modify a parameter by itself works perfectly, however when that parameter is a table, attempting to change the value in that table the value becomes null. I have some examples below:

All are called using this C# code:

object args = new { barcode = "1234567890" };
var resultstr = lua.LuaCall("immutabletest4", args);

Test 1: Here the resultstr is null (Error case!)

function immutabletest(args)
	args.barcode = '1234'
	return args.barcode
end

Test 2: Here resultstr gets the value "1234567890", as it should

function immutabletest2(args)
	barcode = args.barcode or nil
	return barcode
end

Test 3: Here resultstr gets the value "1234567890", as it should

function immutabletest3(args)
	return args.barcode
end

Test 4: Here resultstr gets the value "1234", as it should. I was testing immutability of parameters, and they aren't.

function immutabletest4(barcode)
	barcode = '1234'
	return barcode
end
< 4949 div class="CommentDivider-module__CommentDividerContainer--u90jt">

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0