Skip to content

Array.prototype.join doesn't work on tables #841

@ark120202

Description

@ark120202

Playground

Input:

print([{}].join())

Current Result:

print(
    table.concat({{}}, ",") -- invalid value (table) at index 1 in table for 'concat'
)

Expected Result:

function __TS__ArrayJoin(self, separator)
	if separator == nil then separator = ", " end

	local result = ""
	for index, value in ipairs(self) do
		if index > 1 then
			result = result + separator
		end
		result = result + tostring(value)
	end
	return result
end

print(
    __TS__ArrayJoin({{}}, ",") -- "table: 0x25"
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions