Skip to main content

Select

Used to select singular values from a list of arguments.

Functions

Only

Select.Only(
indexnumber,--

The index of the value to select

...any--

The values to select from

) → any?--

The selected value

Selects the value at the given index.

if Select.Only(2, false, true) then
    -- This will run
end

First

Select.First(
...any--

The values to select from

) → any?--

The first selected value

Selects the first value from the given arguments.

local MyString = "Hello World"
print(Select.First(MyString:gsub("Hello", "World"))) -- "World World"

Last

Select.Last(
...any--

The values to select from

) → any?--

The last selected value

Selects the last value from the given arguments.

print(Select.Last(1, 2, 3)) -- 3

Random

Select.Random(
...any--

The values to select from

) → any?--

The random selected value

Selects a random value from the given arguments.

print(Select.Random(1, 2, 3)) -- 1, 2, or 3
Show raw api
{
    "functions": [
        {
            "name": "Only",
            "desc": "Selects the value at the given index.\n\n```lua\nif Select.Only(2, false, true) then\n    -- This will run\nend\n```",
            "params": [
                {
                    "name": "index",
                    "desc": "The index of the value to select",
                    "lua_type": "number"
                },
                {
                    "name": "...",
                    "desc": "The values to select from",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "The selected value",
                    "lua_type": "any?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 22,
                "path": "src/Packages/Select/init.luau"
            }
        },
        {
            "name": "First",
            "desc": "Selects the first value from the given arguments.\n\n```lua\nlocal MyString = \"Hello World\"\nprint(Select.First(MyString:gsub(\"Hello\", \"World\"))) -- \"World World\"\n```",
            "params": [
                {
                    "name": "...",
                    "desc": "The values to select from",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "The first selected value",
                    "lua_type": "any?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 40,
                "path": "src/Packages/Select/init.luau"
            }
        },
        {
            "name": "Last",
            "desc": "Selects the last value from the given arguments.\n\n```lua\nprint(Select.Last(1, 2, 3)) -- 3\n```",
            "params": [
                {
                    "name": "...",
                    "desc": "The values to select from",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "The last selected value",
                    "lua_type": "any?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 57,
                "path": "src/Packages/Select/init.luau"
            }
        },
        {
            "name": "Random",
            "desc": "Selects a random value from the given arguments.\n\n```lua\nprint(Select.Random(1, 2, 3)) -- 1, 2, or 3\n```",
            "params": [
                {
                    "name": "...",
                    "desc": "The values to select from",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "The random selected value",
                    "lua_type": "any?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 73,
                "path": "src/Packages/Select/init.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Select",
    "desc": "Used to select singular values from a list of arguments.",
    "source": {
        "line": 6,
        "path": "src/Packages/Select/init.luau"
    }
}