types.Table.rawin
Method on every
tableReports 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
key | any | the 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
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 tableOutput:
t.rawin("a") = true
t.rawin("missing") = false
t.rawin("b") = true
"a" in t: trueSee also
rawget | Returns the value stored under key, without going through a metamethod. |
hasindex | Reports whether key is a slot in the table. |
hasvalue | Reports whether value is stored under any key in the table. |
| table | class index |