Can't call opIndex on class property
John C
johnch_atms at hotmail.com
Sun Apr 2 16:31:33 PDT 2006
class NameValue {
char[][char[]] inner;
char[] opIndex(char[] name) {
return inner[name];
}
void opIndexAssign(char[] value, char[] name) {
inner[name] = value;
}
}
class Client {
NameValue pairs_;
this() {
pairs_ = new NameValue;
}
NameValue pairs() {
return pairs_;
}
}
void main() {
Client client = new Client;
client.pairs["One"] = "Two"; // error here
}
Produces "((client).pairs)()["One"] is not an lvalue".
(Windows XP SP2, DMD 0.150)
Changing the offending line to
client.pairs()["One"] = "Two"
removes the error, as does this
client.pairs_["One"] = "Two"
but I'd like to keep it as a property.
More information about the Digitalmars-d-bugs
mailing list