Difference between revisions of "Tostring"
From GiderosMobile
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
− | + | '''Available since:''' Gideros 2011.6<br/> | |
− | ''' | + | '''Class:''' [[(global)]]<br/> |
− | ''' | ||
− | === | + | === Description === |
− | + | Receives an argument of any type and converts it to a string in a reasonable format. | |
− | |||
− | |||
<source lang="lua"> | <source lang="lua"> | ||
(string) = tostring(e) | (string) = tostring(e) | ||
</source> | </source> | ||
− | === | + | For complete control of how numbers are converted, use string.format. |
− | '''e''': (any) | + | |
+ | 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<br/> | ||
− | === | + | === Return values === |
− | ''' | + | '''Returns''' (string) value converted to string or nil<br/> |
{{(global)}} | {{(global)}} |
Revision as of 22:36, 13 May 2022
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