Skip to content

funny thing in array declaration #307

@Harley-quinn-cn

Description

@Harley-quinn-cn

the code in a nut file,it called in a C++ project:

local a =[1,2];
local d = a.resize(5,[1,2,3]);
d[2].append("dd")
foreach (key,val in a){
	print("key:"+key+ "\ttypeKey:"+ typeof(key) +"\tvalue:"+val+"\n");
}
print(d[4][3])

you will find that: The pointer of d[2],d[3],d[4] is same,The change of d[2] used by d[2].append("dd") will affect d[3],d[4]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions