Skip to content

Conversation

@jordan4ibanez
Copy link

I was reading the documentation for string.find and I noticed that in it's own documentation it reads:

/**
  * Looks for the first match of pattern (see §6.4.1) in the string s. If it
  * finds a match, then find returns the indices of s where this occurrence
  * starts and ends; otherwise, it returns nil.
  * /

I see the definition defined as:

function find(
    s: string,
    pattern: string,
    init?: number,
    plain?: boolean
): LuaMultiReturn<[number, number, ...string[]] | []> ;

Perhaps the easiest solution for this would be to simply add optional return parameters as follows:

function find(
    s: string,
    pattern: string,
    init?: number,
    plain?: boolean
): LuaMultiReturn<[number?, number?, ...string[]] | []> ;

So this way, at least you know it might explode instead of blindly walking into an explosion.

Also:
I noticed that string.match could also blow up so I threw that in there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant