What does the hashtag keyword do in roblox studio?

What does that mean? Example of this:
EXAMPLE

1 Like

It returns the amount of indexes in a table
For ex:

local test = {"hi", 1, workspace}
print(#test) --> 3

Adding on:
I forgot to mention that it also works with strings.

local testStrint = "hello"
print(#testString) --> 5
2 Likes
Subject: length operator
Symbol: #
Works with types: string, table

Strings:
local str = "sample"
print(#str) --> 6

Description: Returns number of characters in a string, each character equals 1 byte,
thus it returns number of bytes as well.

Tables:
local array = {"a", "b", "c"}
print(#array)

Description: works on sequence tables/arrays. Dictionary elements have to be counted
manually with pairs.

Complications: Unimaginably large arrays technically negatively impact performance
because of the O(log n) worst case search efficiency.
Returned length can be modified with __len metamethod.
1 Like

thank you so much anirudh851 tysm!!!

Thank You So much MeerkatSpirit for the solution!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.