I see many programmers use " # " in their scripts and I’m just wondering … What is it used for?
5 Likes
The #
operator is used the get the length of a table.
8 Likes
Oh okay.
Thanks!
[30lettersblahblah]
1 Like
You’re welcome! Have a good day!
2 Likes
What did I tell you lol! People help in these forums
3 Likes
Do you even think I understood it smoothly lol. English is not my main language.
Edit: After thinking for minutes, I actually understood it, but Idk why is it important or how it is used.
2 Likes
you will realize how useful this is later.
local t = {}
for i,v in pairs(workspace:GetDescendants()) do
table.insert(t, v)
end
if # t > 10 then
print(# t)
end
3 Likes
It can also be used for getting the length of a string.
print(#"Hello!") -- 6
2 Likes
Oh alright. Thank you:)
[30letters]
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.