I tried to do this
string.len("hi") and strin = "hi" print(#strin)
They both printed two but what I wanted to clarify is if they're exactly the same or a bit different because some thing that are same or similar tend to be a bit different you know what I mean hozei!!
Hello, xxcoordinatorxx!
string.len(string)
and print(#string)
don't really have a big difference, the only one that I can remember is that #
can be used to Tables. I'll give some examples...
local string = "A text" print(string.len(string)) -- This will print '6' print(#string) -- This will print '6'
however,
local string = {"Nice", "Explanation", "Leamir", 12348, true} print(string.len(string)) -- This will print nil, as "string" is now not a string, but a table print(#string) -- This will print 5, as the table "string" have 5 indexes
It is better use #
for strings and tables, as it works for both
Any errors please post a comment and I'll solve
Good Luck with your games