2,736
edits
Red Leader (talk | contribs) (Doc rank()) |
Red Leader (talk | contribs) (→string(): Doc) |
||
| Line 292: | Line 292: | ||
=== string() === | === string() === | ||
{{Nasal doc | {{Nasal doc | ||
|syntax = debug.string(); | |syntax = debug.string(o[, color]); | ||
|text = | |text = Converts its argument to a string and returns it. | ||
|param1 = | |param1 = o | ||
|param1text = | |param1text = Thing to return as a string. | ||
|example1 = | |param2 = color | ||
|param2text = Optional bool specifying whether to output the string with an {{wikipedia|ANSI escape code#Colors|ANSI color code}}. Defaults to <code>'''nil'''</code>. | |||
|example1 = print(debug.string(nil)); # prints "nil" | |||
print(debug.string(1.25)); # prints "1.25" | |||
print(debug.string("Hello, World!")); # prints 'Hello, World!' | |||
print(debug.string(["a", "b", "c"])); # prints "['a', 'b', 'c']" | |||
print(debug.string({ "a": 1, "b": 2, "c": 3 })); # prints "{ a: 1, c: 3, b: 2 }" | |||
print(debug.string(props.globals.getNode("/sim/time/gmt"))); # prints "</sim/time/gmt = '2016-12-04T18:58:18' (STRING, AT, #1)>" (value may be different) | |||
print(debug.string(airportinfo())); # prints "<airport>" | |||
print(debug.string(func(){})); # prints "<func>" | |||
}} | }} | ||