#whats self and when to use it

1 messages · Page 1 of 1 (latest)

sage zealot
#

i’ ve seen people literally spamming self all over the code, but I don’t quite understand what it does.

simple fable
#

in methods of classes, self refers to the object that the method is called from

tepid tapir
dry veldtBOT
#
Program Output
5

sage zealot
#

and oop

#

are there tutorials or something on studio documentTion

sage zealot
tepid tapir
#

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"])
sage zealot
#

alr thanks im gonna spend some time reading the documentations

tepid tapir
sage zealot
#

@tepid tapir do u suggest learning something else before learning these things or should i learn them now?

tepid tapir
#

there's also no incorrect answer

sage zealot
#

do i need to understand a specific concept before learning these things? like something i need to understand them

dry oreBOT
#

studio** You are now Level 5! **studio

tepid tapir
#

i suggest learning as much as you can as fast as you can. as they say, knowledge is power fingerguns

tepid tapir
# sage zealot do i need to understand a specific concept before learning these things? like so...

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.