arrays - What is the difference between Lua tables and classes? -
i'm beginner programming in general , have been trying few different languages. in lua, there tables seem super lists (arrays, dictionaries, lists in one) in lua possible this:
player = { health = 100, attack = 50, mana = 54 } print(player.health)
and return 100. in other programming languages, need make class same output. understanding, lua has classes tables? tables seem act similar same? if not, makes them different , pros , cons of using either?
but understanding, lua has classes tables?
no, not.
lua (ignoring c api stuff) has 1 complex data structure: tables.
you can create class using table. can create kinds of things using table. lua tables flexible, precisely because only data structure lua has.
in lua, every complex thing @ base level table. or if it's c api, userdata.
a class prototype creating objects. declare class has x, y, , z members in it, create object of class type have x, y , z members in it.
you can create lua tables mimic behavior of classes. there's no language construct in lua formally class.
Comments
Post a Comment