Correct misattributed string() details (#222)

* Correct misattributed `string()` details
This commit is contained in:
Brandon Buck 2019-10-24 03:18:38 -05:00 committed by geseq
parent 1ee7425c9d
commit c3e41c2588

View file

@ -50,6 +50,14 @@ type_name("str") // string
type_name([1, 2, 3]) // array 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. 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 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 ## 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. 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.