clarifications around 'str'
This commit is contained in:
1 parent
2ec095a1bf
commit
15ac3edc19
2 files changed
+11
-4
No files matched your search
@@ -46,15 +46,22 @@ number('3bar') => null
|
|||||||
number('2')+number('2') => 4
|
number('2')+number('2') => 4
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
### `str(expr, params? ... ), str(expr, param_list)`
|
### `str(expr)`,`str(expr, params? ... )`, `str(expr, param_list)`
|
||||||
|
|
||||||
Returns a formatted string representing expression. Accepts formatting style accepted by `String.format`.
|
If called with one argument, returns string representation of such value.
|
||||||
Supported types (with `"%?"` syntax):
|
|
||||||
|
Otherwise, returns a formatted string representing the expression. Arguments for formatting can either be provided as
|
||||||
|
each consecutive parameter, or as a list which then would be the only extra parameter. To format one list argument
|
||||||
|
, you can use `str(list)`, or `str('foo %s', l(list))`.
|
||||||
|
|
||||||
|
Accepts formatting style accepted by `String.format`.
|
||||||
|
Supported types (with `"%<?>"` syntax):
|
||||||
|
|
||||||
* `d`, `o`, `x`: integers, octal, hex
|
* `d`, `o`, `x`: integers, octal, hex
|
||||||
* `a`, `e`, `f`, `g`: floats
|
* `a`, `e`, `f`, `g`: floats
|
||||||
* `b`: booleans
|
* `b`: booleans
|
||||||
* `s`: strings
|
* `s`: strings
|
||||||
|
* `%%`: '%' character
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
str(null) => null
|
str(null) => null
|
||||||
|
|||||||
@@ -1575,7 +1575,7 @@ public class Expression
|
|||||||
if (lv.size() == 1)
|
if (lv.size() == 1)
|
||||||
return new StringValue(format);
|
return new StringValue(format);
|
||||||
int argIndex = 1;
|
int argIndex = 1;
|
||||||
if (lv.get(1) instanceof ListValue)
|
if (lv.get(1) instanceof ListValue && lv.size() == 2)
|
||||||
{
|
{
|
||||||
lv = ((ListValue) lv.get(1)).getItems();
|
lv = ((ListValue) lv.get(1)).getItems();
|
||||||
argIndex = 0;
|
argIndex = 0;
|
||||||
|
|||||||
Reference in new issue
Block a user