[DiscordArchive] hmm, but in your examples there the classname is nowhere as string, would that matter?
[DiscordArchive] hmm, but in your examples there the classname is nowhere as string, would that matter?
Archived author: Grandold • Posted: 2022-05-16T17:47:43.250000+00:00
Original source
but hmm, why () after v as its just a class name?
Archived author: Grandold • Posted: 2022-05-16T17:48:48.932000+00:00
Original source
assuming the class was just a collection of functions and would not return itself upon creation, would that work the same way?
Archived author: Grandold • Posted: 2022-05-16T17:49:26.561000+00:00
Original source
like, if the classes A and B got, and got only the function :get()
Archived author: Grandold • Posted: 2022-05-16T17:49:56.190000+00:00
Original source
im pretty sure I tried that just like calling v:get() and it just didnt work at all
Archived author: Grandold • Posted: 2022-05-16T17:50:40.246000+00:00
Original source
I mean, I hope I'm wrong x)
Archived author: Grandold • Posted: 2022-05-16T17:54:32.048000+00:00
Original source
```
local classes = { 'A', 'B' }
A = {}
function A:get ()
return '123'
end
B = {}
function B:get ()
return 'xyz'
end
for k, v in pairs(classes) do
v():get()
end
```
tested this in lua.org demo emulator and it gives same errors I was getting I think
![[Image: unknown.png?ex=690c3844&is=690ae6c4&hm=1...d842be54b&]](https://cdn.discordapp.com/attachments/448835144564867094/975818735543791697/unknown.png?ex=690c3844&is=690ae6c4&hm=197cd2318a1019f4ca1dab720af981c8dd72dffedee461f7c2ae362d842be54b&)
Archived author: Foe • Posted: 2022-05-16T17:55:16.548000+00:00
Original source
![[Image: unknown.png?ex=690c3844&is=690ae6c4&hm=1...d842be54b&]](https://cdn.discordapp.com/attachments/448835144564867094/975818735543791697/unknown.png?ex=690c3844&is=690ae6c4&hm=197cd2318a1019f4ca1dab720af981c8dd72dffedee461f7c2ae362d842be54b&)
Archived author: Grandold • Posted: 2022-05-16T17:55:48.875000+00:00
Original source
cool, didnt realize k and v are automatically in global scope
Archived author: Foe • Posted: 2022-05-16T17:56:02.946000+00:00
Original source
They're not, that's what _G defines
Archived author: Foe • Posted: 2022-05-16T17:56:14.584000+00:00
Original source
that's the variable to access the global namespace, k and v are local values