String.rep() 3rd argument?

I’m very confused…

On the wiki and API reference, it says that there is this “sep” argument, but it doesn’t seem to work… I have searched far and wide for this, and I can’t find any info…
image

1 Like

This has been an issue for at least the past couple months. Can reproduce.

1 Like

Guess I’ll just write my own function

This looks like a case of the documentation being incorrect, since there is no code to handle a third argument, and this third argument doesn’t exist in vanilla Lua 5.1.

7 Likes

In case anyone is wondering how to make your own repeat function that does allow for a separator parameter, I made this (i know you could us a for loop, but this is more fun :wink:):

local function rep(s, n, sep)
	local ByteString = table.concat({s:byte(1, #s)}, ",")
	return ByteString:rep(n):gsub(ByteString, function(match)
		return string.char(unpack(match:split(","))).. sep
	end):sub(1, -#sep - 1)
end
3 Likes