From c3e41c2588a21cdf4aebebff23de0817405e5768 Mon Sep 17 00:00:00 2001 From: Brandon Buck Date: Thu, 24 Oct 2019 03:18:38 -0500 Subject: [PATCH] Correct misattributed `string()` details (#222) * Correct misattributed `string()` details --- docs/builtins.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/builtins.md b/docs/builtins.md index 4bb65a9..a512b6f 100644 --- a/docs/builtins.md +++ b/docs/builtins.md @@ -50,6 +50,14 @@ type_name("str") // string type_name([1, 2, 3]) // array ``` +## string + +Tries to convert an object to string object. See [Runtime Types](https://github.com/d5/tengo/blob/master/docs/runtime-types.md) for more details on type conversion. + +```golang +x := string(123) // x == "123" +``` + Optionally it can take the second argument, which will be returned if the first argument cannot be converted to string. Note that the second argument does not have to be string. @@ -58,14 +66,6 @@ v = string(undefined, "foo") // v == "foo" v = string(undefined, false) // v == false ``` -## string - -Tries to convert an object to string object. See [Runtime Types](https://github.com/d5/tengo/blob/master/docs/runtime-types.md) for more details on type conversion. - -```golang -x := string(123) // v == "123" -``` - ## int Tries to convert an object to int object. See [this](https://github.com/d5/tengo/blob/master/docs/runtime-types.md) for more details on type conversion.