Actually return those lists

This commit is contained in:
altrisi committed 2021-01-14 03:08:33 +01:00
1 parent 852139d936
commit 9eea3b47a6
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;