Skip to content

Commit

Permalink
adds contains for dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
brwhale committed Jun 23, 2023
1 parent 9f7f1d8 commit f685b55
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/Library/modulesImplementation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1136,12 +1136,15 @@ namespace KataScript {
break;
}
return make_shared<Value>(Int(0));
}
auto& list = args[0]->getList();
for (size_t i = 0; i < list.size(); ++i) {
if (*list[i] == *args[1]) {
return make_shared<Value>(Int(1));
} else if (args[0]->getType() == Type::List) {
auto& list = args[0]->getList();
for (size_t i = 0; i < list.size(); ++i) {
if (*list[i] == *args[1]) {
return make_shared<Value>(Int(1));
}
}
} else if (args[0]->getType() == Type::Dictionary) {
return make_shared<Value>(Int(args[0]->getDictionary()->contains(args[1]->getHash())));
}
return make_shared<Value>(Int(0));
}},
Expand Down

0 comments on commit f685b55

Please sign in to comment.