Returns a table’s delegate
Device + Agent
Table — the target’s current delegate, otherwise null
This method returns the target table’s current custom delegate, or null
if no such delegate has yet been assigned.
local mt = {}; | |
local md = {}; | |
// Give MD - but *not* MT - a name slot with a function as a value | |
md.name <- function() { | |
server.log(this.title); | |
}; | |
// Give both tables a title slot with strings as values | |
mt.title <- "My Table"; | |
md.title <- "My Delegate"; | |
// Make MD the delegate of MT | |
mt.setdelegate(md); | |
// MT does not have a slot 'name', so Squirrel will try its delegate | |
// when the we ask it to access 'name' in MT: | |
mt.name(); | |
// Displays "My Table" | |
if (mt.getdelegate() == md) server.log("MD is the delegate of MT"); | |
// Displays "MD is the delegate of MT" |