ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
REQUIRE_NOT_NULL(self);
-
- Value result;
- bool first = true;
-
- ObjectLock olock(self);
- for (const Value& item : self) {
- if (first) {
- first = false;
- } else {
- result = result + separator;
- }
-
- result = result + item;
- }
-
- return result;
+ return self->Join(separator);
}
static Array::Ptr ArrayReverse()
return msgbuf.str();
}
+Value Array::Join(const Value& separator) const
+{
+ Value result;
+ bool first = true;
+
+ ObjectLock olock(this);
+
+ for (const Value& item : m_Data) {
+ if (first) {
+ first = false;
+ } else {
+ result = result + separator;
+ }
+
+ result = result + item;
+ }
+
+ return result;
+}
+
Array::Ptr Array::Unique() const
{
std::set<Value> result;
void Sort(bool overrideFrozen = false);
String ToString() const override;
+ Value Join(const Value& separator) const;
Array::Ptr Unique() const;
void Freeze();