Skip to content

Commit

Permalink
Fixed #53
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborsch committed Apr 21, 2024
1 parent fecffb9 commit 300b2d6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Binary file modified rocky.jar
Binary file not shown.
13 changes: 5 additions & 8 deletions src/rockstar/statement/JoinStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package rockstar.statement;

import java.util.List;
import java.util.StringJoiner;

import rockstar.expression.MutationExpression;
import rockstar.runtime.BlockContext;
Expand All @@ -31,17 +32,13 @@ public void execute(BlockContext ctx) {
// evaluate separator, use default if not present
String sep = (expr.getParameterExpr() == null) ? "" : expr.getParameterExpr().evaluate(ctx).getString();
// JOIN the array into a string
StringBuilder sb = new StringBuilder();
StringJoiner sj = new StringJoiner(sep);
arrayValue.stream()
.filter(v -> (!v.isNull() && !v.isMysterious()))
.forEachOrdered(v -> {
if (sb.length() > 0) {
sb.append(sep);
}
sb.append(v.getString());
});
.map(Value::getString)
.forEachOrdered(sj::add);
// get string vale
Value stringValue = Value.getValue(sb.toString());
Value stringValue = Value.getValue(sj.toString());

// assign the value to the variable
AssignmentStatement.assign(expr.getTargetReference(), stringValue, ctx);
Expand Down

0 comments on commit 300b2d6

Please sign in to comment.