Encapsulation
class Person {
-- This variable can't be accessed outside the class
private age: number,
constructor(age: number)
self.age = age
end,
function getAge(): string
return "This person is " .. age .. " years old."
end
}
local p: Person = Person(100)
print(p.getAge()) -- OK
print(p.age) -- Error, since age is privateLast updated