The "in" operator


On the Squirrel Programming Guide (, there is this example:

if (firstKey in myTable) {
// ‘myTable’ has the key ‘firstKey’ so set it
myTable.firstKey = “Rowdy Yates Block”;

I get this error: the index ‘firstKey’ does not exist. I have to put quotes around firstKey for this to work: if (“firstKey” in myTable) {

Is this a documentation error or am I missing something?


Yeah, that would appear to be a documentation error. It should be quoted, as you have it. Unless, of course, you had:

local keyName = "firstKey"; if (keyName in myTable) { /* ... */ }

I’ll alert the documentation team.


Documentation updated! Thanks for the find, @Kitty.