Mtasa-blue: Refactor rest parameters

Created on 26 Jun 2019  路  2Comments  路  Source: multitheftauto/mtasa-blue

Describe the solution you'd like
We all know what rest parameters are, but do we need it? I think that more common could be use array instead of this "..." syntax (or "param1, param2, ..."). For example this:

dbQuery(conn, "INSERT INTO users (name, surname, email, password) VALUES (?, ?, ?, ?)", "P", "M", "[email protected]", "test123")

could be this:

dbQuery(conn, "INSERT INTO users (name, surname, email, password) VALUES (?, ?, ?, ?)", {"P", "M", "[email protected]", "test123"})

which for me is more practical (and cleaner) because I can have declared object or array of variables higher

local values = {"P", "M", "[email protected]", "test123"}
dbQuery(conn, "INSERT INTO users (name, surname, email, password) VALUES (?, ?, ?, ?)",  values)

Also people who are trying to add some type-based languages like C# could have less work to do because as i remember those languages doesn't support rest parameters.

enhancement wontfix

Most helpful comment

local values = {"P", "M", "[email protected]", "test123"}
dbQuery(conn, "INSERT INTO users (name, surname, email, password) VALUES (?, ?, ?, ?)",  unpack(values))

All 2 comments

local values = {"P", "M", "[email protected]", "test123"}
dbQuery(conn, "INSERT INTO users (name, surname, email, password) VALUES (?, ?, ?, ?)",  unpack(values))

Will not fix as you can use the built in unpack function.
See @CrosRoad95's answer above.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PlatinMTA picture PlatinMTA  路  3Comments

qaisjp picture qaisjp  路  4Comments

CrosRoad95 picture CrosRoad95  路  4Comments

commanderagu picture commanderagu  路  3Comments

Haxardous picture Haxardous  路  3Comments