Actually return those lists
This commit is contained in:
1 file changed
+6
-1
@@ -350,12 +350,17 @@ public class ListValue extends AbstractListValue implements ContainerValueInterf
|
|||||||
@Override
|
@Override
|
||||||
public Value split(Value delimiter) {
|
public Value split(Value delimiter) {
|
||||||
ListValue result = new ListValue();
|
ListValue result = new ListValue();
|
||||||
|
if (delimiter == null)
|
||||||
|
{
|
||||||
|
this.forEach(item -> result.items.add(of(item)));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
int startIndex = 0;
|
int startIndex = 0;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (Value val : this.items)
|
for (Value val : this.items)
|
||||||
{
|
{
|
||||||
index++;
|
index++;
|
||||||
if (val.equals(delimiter) || delimiter == null)
|
if (val.equals(delimiter))
|
||||||
{
|
{
|
||||||
result.items.add(ListValue.wrap(this.items.subList(startIndex, index-1)));
|
result.items.add(ListValue.wrap(this.items.subList(startIndex, index-1)));
|
||||||
startIndex = index;
|
startIndex = index;
|
||||||
|
|||||||
Reference in new issue
Block a user