Skip to content

Commit 1fd2dd8

Browse files
committed
Исправлена проверка типов в функции foreach
1 parent 1f1a5ed commit 1fd2dd8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/com/annimon/ownlang/lib/modules/functions/std_foreach.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ public final class std_foreach implements Function {
1010
public Value execute(Value... args) {
1111
if (args.length != 2) return NumberValue.ZERO;
1212

13-
if (!(args[1] instanceof FunctionValue)) return NumberValue.ZERO;
13+
if (args[1].type() != Types.FUNCTION) return NumberValue.ZERO;
1414
final Function function = ((FunctionValue) args[1]).getValue();
1515
final Value container = args[0];
16-
if (container instanceof ArrayValue) {
16+
if (container.type() == Types.ARRAY) {
1717
final ArrayValue array = (ArrayValue) container;
1818
for (Value element : array) {
1919
function.execute(element);
2020
}
2121
return NumberValue.ZERO;
2222
}
23-
if (container instanceof MapValue) {
23+
if (container.type() == Types.MAP) {
2424
final MapValue map = (MapValue) container;
2525
for (Map.Entry<Value, Value> element : map) {
2626
function.execute(element.getKey(), element.getValue());

0 commit comments

Comments
 (0)