Difference between revisions of "Tostring"
From ComputerCraft Wiki
m (NeedsWork -> Stub) |
(Un-stub'ed document (w/h templates & examples!).) |
||
| Line 1: | Line 1: | ||
| − | {{ | + | {{lowercase}} |
| − | + | {{Function | |
| + | |name=tostring | ||
| + | |args=Object o | ||
| + | |returns=[[string (type)|string]] representation of the Object <var>o</var> | ||
| + | |api=none | ||
| + | |addon=Lua | ||
| + | |desc=Converts any passed object to it's string-representation. | ||
| + | |examples= | ||
| + | {{Example | ||
| + | |desc=Convert an [[int (type)|integer]] to a [[string (type)|string]] | ||
| + | |code=local a = tostring(1) | ||
| + | |output= a = "1" ([[string (type)|string]]) | ||
| + | }} | ||
| + | {{Example | ||
| + | |desc=Convert a [[float (type)|float]] to a [[string (type)|string]] | ||
| + | |code=local b = tostring(3.1415) | ||
| + | |output= b = "3.1415" ([[string (type)|string]]) | ||
| + | }} | ||
| + | }} | ||
| + | |||
[[Category:Lua_Core_Functions]] | [[Category:Lua_Core_Functions]] | ||
Revision as of 23:34, 28 November 2012
| Converts any passed object to it's string-representation. | |
| Syntax | tostring(Object o) |
| Returns | string representation of the Object o |
| Part of | Lua |
| API | none |
Examples
| Convert an integer to a string | |
| Code |
local a = tostring(1) |
| Output | a = "1" (string) |
| Convert a float to a string | |
| Code |
local b = tostring(3.1415) |
| Output | b = "3.1415" (string) |