diff options
| author | rebecca <ubq323@ubq323.website> | 2026-09-26 21:46:41 +0100 |
|---|---|---|
| committer | rebecca <ubq323@ubq323.website> | 2026-09-26 21:46:41 +0100 |
| commit | 5107345463be25bc471274bc82c503ba2acdf5b4 (patch) | |
| tree | f1f1a8aec7af43fbc37faf43bb710f2d456e5b2b /class.lua | |
| parent | 753803362cd516fb461d57efba18f9a32916106d (diff) | |
class: add is(obj, cls)
Diffstat (limited to 'class.lua')
| -rw-r--r-- | class.lua | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -23,9 +23,20 @@ local function extend(Base) return T end +local function is(obj, cls) + if not type(obj) == 'table' then return false end + local mt = getmetatable(obj).__index + while mt do + if rawequal(cls, mt) then return true end + mt = (getmetatable(mt) or {}).__index + end + return false +end + return setmetatable({ class=class, - extend=extend + extend=extend, + is=is, },{__call=class}) |
