Quirrel4.41.0

types.Table.rawin

Method on every table
pure table.rawin(key): any

Reports whether key is a slot in the table, without calling a metamethod.

The binding carries no declaration string, so the VM cannot report parameter names. The names above are from this page; the types and attributes still come from the VM. The VM also cannot tell an optional parameter from a variadic tail here, so read the brackets and any trailing ... from the prose below, not from the signature.

Parameters

keyanythe key to test

Return value

true if key names a slot in the table, false otherwise.

Notes

Takes exactly one argument; t.rawin() throws a wrong-number-of-parameters error.

Same result as hasindex on a table: both go through sq_rawget and never consult a _get metamethod. The in operator, key in t, is close but technically not raw - it still runs the metamethod-aware lookup - yet for a table it always agrees with rawin anyway, because a table's _get can only come from a delegate, and script code has no way to attach one (see getfuncinfos).

Example

examples/types/table/rawin.nut
let t = {a=1, b=null}
println("t.rawin(\"a\") =", t.rawin("a"))
println("t.rawin(\"missing\") =", t.rawin("missing"))
println("t.rawin(\"b\") =", t.rawin("b"))       // present with a null value: still true
println("\"a\" in t:", "a" in t)           // the 'in' operator agrees for a plain table
Output:
t.rawin("a") = true
t.rawin("missing") = false
t.rawin("b") = true
"a" in t: true

See also

rawgetReturns the value stored under key, without going through a metamethod.
hasindexReports whether key is a slot in the table.
hasvalueReports whether value is stored under any key in the table.
tableclass index