lua-users home
lua-l archive

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



> myObj = {}
> myObj.xPos = 10;
> myObj.someVal = 100;

> Now, I would like it if I could write a function:

> function myObj.update()
>    --some code
>    someVal = xPos * 10
>    --remaining code
> end


do
  myObj = {}
  local xPos, someVal = 10, 100;
  function myObj.update()
    -- some code
    someVal = xPos + 10
    -- some more code
  end
end

This means myObj's xPos and someVal are completely private. Some would say that was a Good Thing.