#whats self and when to use it
1 messages · Page 1 of 1 (latest)
it's for OOP
in methods of classes, self refers to the object that the method is called from
;compile lua lua local t={ x=5 } function t.foo(self) print(self.x) end t:foo() -- notice how there's no arguments. the : implies 'self'.
5
what is .too?
and oop
are there tutorials or something on studio documentTion
oh so it is used for tables?
To represent records, you use the field name as an index. Lua supports this representation by providing a.name as syntactic sugar for a["name"]. So, we could write the last lines of the previous example in a cleanlier manner as
a.x = 10 -- same as a["x"] = 10 print(a.x) -- same as print(a["x"]) print(a.y) -- same as print(a["y"])
alr thanks im gonna spend some time reading the documentations
Object-oriented programming (OOP) is a programming paradigm based on the concept of objects. Objects can contain data (called fields, attributes or properties) and have actions they can perform (called procedures or methods and implemented in code). In OOP, computer programs are designed by making them out of objects that interact with one anoth...
@tepid tapir do u suggest learning something else before learning these things or should i learn them now?
there is no correct answer to this.
there's also no incorrect answer
i mean
do i need to understand a specific concept before learning these things? like something i need to understand them
** You are now Level 5! **
i suggest learning as much as you can as fast as you can. as they say, knowledge is power 
there's no correct order to learn things in. you either understand it or you don't. if you don't, you don't know enough to understand the concept yet, like understand the P=NP problem, you need to know some things about how code performance works before you can understand the problem, and that's not like some kind of gated knowledge, that's just the sheer nature of the problem, so you'll know quite fast if you need to learn more basics before learning the thing you're looking at.
i understand thanks👍😁