1. Hello,

    I've been looking at Chapter 4 of the 2d Edition, trying to understand the OOP section. I thought I had a handle on it, until I tried a simple experiment of "wrapping" a Blizzard Frame object with code of my own. (I'm a novice with the OOP terminology; maybe it's actually the Frame that's wrapping my code.) For some reason I can't understand, this code doesn't work:

    MyBlizzardFrame = {}

    function MyBlizzardFrame:new(o)

    local o = o or CreateFrame("Frame")

    setmetatable(o, self)

    self.__index = self

    return o


    function MyBlizzardFrame:test(x) print("Foo: " .. x) end

    x = MyBlizzardFrame:new()

    x:test("hello") -- outputs "Foo: hello" as expected

    print(x:GetObjectType()) -- error!

    So the call to MyBlizzardFrame:test(x) works as I expected, but the call to GetObjectType doesn't work. (Attempt to call method: 'GetObjectType' (a nil value).)

    Any ideas what I'm doing wrong? I thought that the "setmetatable" technique would only look up into the __index object if the parser couldn't find a function in the current object. I'm just not seeing why the parser isn't finding GetObjectType in the current object (a Frame).