Object-Oriented Programming: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
Lua is a duck typed language - yada, yada, yada...
>NXTBoy
>Nightname
(Lua is a duck typed language - yada, yada, yada...)
Line 1: Line 1:


A [[Tables|table]] in [[Lua]] is an object in more than one sense. Like objects, tables have a state. Like objects, tables have an identity (a selfness) that is independent of their values; specifically, two objects (tables) with the same value are different objects, whereas an object can have different values at different times, but it is always the same object. Like objects, tables have a life cycle that is independent of who created them or where they were created.  
As Lua supports duck typing through the use of [[Metatables|metatable]], the ability to create "objects" can be achieved. This is essentially objected-oriented programming. A [[Tables|table]] in [[Lua]] is an object in more than one sense. Like objects, tables have a state. Like objects, tables have an identity (a selfness) that is independent of their values; specifically, two objects (tables) with the same value are different objects, whereas an object can have different values at different times, but it is always the same object. Like objects, tables have a life cycle that is independent of who created them or where they were created.  


Objects have their own operations. Tables also can have operations:  
Objects have their own operations. Tables also can have operations:  
Anonymous user

Navigation menu