Tostring: Difference between revisions
From GiderosMobile
No edit summary |
No edit summary |
||
| (2 intermediate revisions by one other user not shown) | |||
| Line 5: | Line 5: | ||
=== Description === | === Description === | ||
Receives an argument of any type and converts it to a string in a reasonable format. | Receives an argument of any type and converts it to a string in a reasonable format. | ||
< | <syntaxhighlight lang="lua"> | ||
(string) = tostring(e) | (string) = tostring(e) | ||
</ | </syntaxhighlight> | ||
For complete control of how numbers are converted, use string.format. | For complete control of how numbers are converted, use string.format. | ||
| Line 18: | Line 18: | ||
=== Return values === | === Return values === | ||
'''Returns''' (string) value converted to string or nil<br/> | '''Returns''' (string) value converted to string or nil<br/> | ||
=== See also === | |||
'''https://luau.org/library#global-functions'''<br/> | |||
{{(global)}} | {{(global)}} | ||
Latest revision as of 10:26, 21 July 2025
Available since: Gideros 2011.6
Class: (global)
Description
Receives an argument of any type and converts it to a string in a reasonable format.
(string) = tostring(e)
For complete control of how numbers are converted, use string.format.
If the metatable of e has a "__tostring" field, then tostring calls the corresponding value with e as argument, and uses the result of the call as its result.
Parameters
e: (any) value to convert to string
Return values
Returns (string) value converted to string or nil
See also
https://luau.org/library#global-functions