Skip to content

Wrap array-returning APIs #3

Open

Description

@Cheatoid

Currently, it is inconsistent and also confusing whether a developer should use 0-based indexing or 1-based indexing.
For example:

print(player.GetAll()[1])

The above code will actually not work, a temporary workaround is available for dealing with this issue:

print(player.GetAll().get(1))

The get method uses 1-based indexing and will therefore return the first player from the table.

Another example is that someone may be tempted to iterate players like so:

foreach (var ply in player.GetAll()) {
    print(ply.Name);
}

However that does not work currently, a temporary workaround is available for dealing with this issue:

player.GetAll().each((ply) => {
    print(ply.Name);
});

By using custom loop API, you will get the expected result.

Activity

  1. added
    bug
    on Feb 1, 2021
  2. self-assigned this
    on Feb 1, 2021
  3. added this to the vNext milestone on Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-coresystembug

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions