I've seen it alot but I can't find any explanation. Could someone explain what it does and what it is used for?
COMMUNITY QUESTION
Could someone explain to me what tostring does and what it can be used for?
1 answer
tostring converts a Number Value such as 1,2,3..99 etc. into a String
For example tostring("50") converts the string "50" to the number 50 Example usage is shown here, which is copied from the wiki:
print("50" == 50) -- false, because a string is not equal to a number.
print(tostring(50) == "50") -- true, because you converted the number 50 to a string
print(tonumber("50") == 50) -- true, because you converted the string "50" to a number
print(50 .. "" == "50") -- true, because you tacked on an empty string to the end of the number 50, converting 50 to a string.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Tostring is a function almost universal across programming languages as well such as Java and Javascript, Python, and C# from my experience. It should take an object given to the function and convert it to a string. Whether it returns the name of the object or information of the object is up to the language's interpreter or compiler.