string indexing

stl_dim
Brad Pitcher 2011-11-12 22:58:15 -08:00
parent 2cfcdf557d
commit dcf4b83306
1 changed files with 5 additions and 0 deletions

View File

@ -85,6 +85,11 @@ Value Expression::evaluate(const Context *context) const
if (i >= 0 && i < int(v1.vec.size())) if (i >= 0 && i < int(v1.vec.size()))
return *v1.vec[i]; return *v1.vec[i];
} }
if (v1.type == Value::STRING && v2.type == Value::NUMBER) {
int i = (int)(v2.num);
if (i >= 0 && i < v1.text.size())
return Value(v1.text.substr(i, 1));
}
return Value(); return Value();
} }
if (this->type == "I") if (this->type == "I")