Difference between revisions of "Tostring"

From GiderosMobile
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
<languages />
+
'''Available since:''' Gideros 2011.6<br/>
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
+
'''Class:''' [[(global)]]<br/>
'''<translate>Class</translate>:''' [[Special:MyLanguage/(global)|(global)]]<br/>
 
  
=== <translate>Description</translate> ===
+
=== Description ===
<translate>Receives an argument of any type and converts it to a string in a reasonable format. For complete control of how numbers are converted, use string.format.
+
Receives an argument of any type and converts it to a string in a reasonable format.
 +
<syntaxhighlight lang="lua">
 +
(string) = tostring(e)
 +
</syntaxhighlight>
  
  If the ''metatable'' of e has a "__tostring" field, then [[Special:MyLanguage/tostring|tostring]] calls the corresponding value with e as argument, and uses the result of the call as its result.</translate>
+
  For complete control of how numbers are converted, use string.format.
<source lang="lua">
+
 
(string) = tostring(e)
+
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.
</source>
 
  
=== <translate>Parameters</translate> ===
+
=== Parameters ===
'''e''': (any) <translate>value to convert to string</translate> <br/>
+
'''e''': (any) value to convert to string<br/>
  
=== <translate>Return values</translate> ===
+
=== Return values ===
'''<translate>Returns</translate>''' (string) <translate>value converted to string or nil</translate><br/>
+
'''Returns''' (string) value converted to string or nil<br/>
  
 
{{(global)}}
 
{{(global)}}

Latest revision as of 15:33, 13 July 2023

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