correct method of a using a table

Started by Mötley, Oct 10, 2016, 08:27 PM

Previous topic - Next topic

Mötley

I'm rusty..


But this would be a correct method of a using a table instead of a class correct?

local Peripheral = {
    pins = {},
    id = 0,

    function setID(value) {
        if (value > -1 && value < 256) {
            id = value;
        }
    }
}

Peripheral.setID(4);

Just a standard question

jWeb

Sure, think of them as namespaces. Although, if you want to access it in other files, you might want to make it global `Peripheral <- {  };`

Mötley