Quirrel4.53.0

types.Table.rawin

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

Reports whether key is a slot in the table.

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. The in operator, key in t, also agrees with rawin on a table, because a table has no _get metamethod.

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.
hasindexReports whether key is a slot in the table.
hasvalueReports whether value is stored under any key in the table.
tableclass index