lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello,

What's the accepted practice to somehow "overload" methods in Lua?

Presently, I'm using the type() function to more or less achieve the same effect.

For example, the following method accepts either a "number" or something else and act accordantly:

        local function get( anIndex )
                if type( anIndex ) ~= "number" then
                        anIndex = indexOf( anIndex )
                end

                return ivars[ anIndex ]
        end

Is that a reasonable approach? Alternatives?

Thanks!

Cheers

--
PA, Onnay Equitursay
http://alt.textdrive.com/