Lets say I have a table that looks like this
local t = {"x","yy","xyz"}
As you can see xys is larget than xand yy, but I want a function that i can use that automatically finds the length of the largest value in a table/array
Lets say I have a table that looks like this
local t = {"x","yy","xyz"}
As you can see xys is larget than xand yy, but I want a function that i can use that automatically finds the length of the largest value in a table/array
Perhaps this is not the most efficient approach (it seems like there always is a better way), but you can use a variable to keep track of the longest item you've found so far while looping through the table and checking the lengths of each item.
Example:
local longest = 0
for i, v in pairs(t) do
if #v > longest then
longest = #v
end
end
Let me know if this helps!
This discussion is preserved as it was. New answers, comments, and votes are closed.